[Zope] Knowing the Zope database is configured read-only
tim.peters at gmail.com
Thu Feb 17 15:01:26 EST 2005
>> Is there a simple way to know from code (zpt, script, Condition of
>>actions) that the main database has been set read-only ?
> I do not know of a simple way -- but a complex one:
> If "obj" is a persistent object, then "obj._p_jar" is
> its ZODB connection (that loaded it from the ZODB).
> If "conn" is a ZODB connection, then "conn._storage" is
> its ZODB storage.
> If "storage" is a storage, then, usually, you
> can check the "_is_read_only" attribute to determine
> As you see from the "_" prefix in attribute, this
> method requires trusted code (e.g. an External Method).
FWIW, both storages and connections support the isReadOnly() method;
you don't have to (and shouldn't) muck around looking at private
attributes like _storage or _is_read_only, and in the case of a ZEO
client connection _is_read_only alone doesn't tell the full story (but
More information about the Zope