[Zope] Persistent object in volatile dictionary on a per thread basis

Martijn Pieters mj at zopatista.com
Mon Nov 20 15:05:47 EST 2006


Please keep this on the list; the collective list community far  
outsmarts just me, so give them a chance to give input too.

On 20 Nov 2006, at 14:29, Marco Bizzarri wrote:
>> Yes, it is perfectly legal. All attributes starting with _v are
>> considered volatile and won't be persisted, including dictionaries
>> stored as such attributes.
>
> Sorry, I did not explain well: I'm not using _v_ attributes (because
> they are not transactional, basically).

You cannot have both transactional and volatile, as transactions only  
apply to ZODB-stored (persistent) attributes.

>> > Is it possible to have the dreaded error, i.e.
>> >
>> > exceptions.RuntimeError
>> > Shouldn't load state for 0x01254260 when the connection is closed
>>
>> That error would not be connected to _v volatile attributes, as they
>> are skipped when storing and are therefor not present when loading.
>> The error has to do with a closed ZODB database connection instead,
>> for whatever reason.
>
> I usually get this kind of error when I store a reference to a
> persistent object in a non persistent attribute, like a dictionary
> definied at module level, and then try to access it from  a different
> thread...

Yes, you should not store persistent attribute references outside of  
the ZODB object tree. Store paths instead, then resolve the path  
after retrieving it in whatever thread you are in.

--
Martijn Pieters



More information about the Zope mailing list