-----BEGIN PGP SIGNED MESSAGE-----
Florent Guillaume wrote:
> Jim Washington wrote:
>> Spelunking a bit in the code,
>> zope.app.rdb.ZopeDatabaseAdapter.isConnected() looks at whether
>> _v_connection is present, not whether the connection is actually
>> alive. If we fix this here, isConnected() perhaps should handle the
>> case where the connection might be reaped by the back end db.
> Frankly anything that uses _v_ attributes is asking for trouble because
> it relies on low level behaviour of the ZODB and persistence mechanisms.
> They can disappear at unpredictable times. Avoid them.
There *is* a reasonable pattern for using them, with the following
caveat: the value you are caching must depend *only* on other
attribtues of the *same* persistent object *or* its non-persistent
subobjects (i.e., the values are pickled / ghostified as part of the
same ZODB record).
In this case, the following works entirely as expected:
_v_cache_an_expensive_operation = None
if self._v_cache_an_expensive_operation is None:
self._v_cache_an_expensive_operation = _expensive()
This pattern is reliable because the volatile will be wiped if *any* of
the attributes of its object are modified, at the point that the
transaction (or subtransaction) commits / reaches a savepoint.
If '_expensive' depends on *any other persistent object*, you lose
Tres Seaver +1 202-558-7113 [EMAIL PROTECTED]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Zope3-dev mailing list