[ZODB-Dev] persisting "immutable" classes

Dieter Maurer dieter at handshake.de
Sat Feb 28 06:19:09 EST 2004


John Belmonte wrote at 2004-2-26 17:32 -0500:
>I've caught myself a few times storing class instances in the database 
>which are not derived from Persistent.  If I never mutate the instance's 
>attributes once it is stored, is it wrong to do so?

When you attach a non-persitent object to a persistent
one, it will get part of this persistent object (as far
as the persistency mechanism is concerned).
Whether this is adequate is application dependent.

Beware, however, that the containing persistent object does
not recognized modifications of the non-persistent object.
If you are not careful, modifications may be lost -- in an
apparently non-deterministic fashion (it is in fact
deterministic but asynchronous to "normal" operation).


-- 
Dieter



More information about the ZODB-Dev mailing list