[Zope] What kind of attributes can be put inside a simple item

Dieter Maurer dieter at handshake.de
Fri Feb 18 14:51:42 EST 2005


Marco Bizzarri wrote at 2005-2-18 10:36 +0100:
> ... Non persistent attribute of persistent object ...
>I always understood that I could not put Alfa instances inside a Beta 
>class, because the ZODB machinery did not understood how to pickle them. 

Every persistent object must be picklable.
Therefore, all non-volatile attributes of a persistent object
must be picklable.

However, the class of picklable objects is much larger then
just persistent objects.

In principle, you can use any picklable object as
attribute of a persistent object.

However, you must be careful, when you change something
inside such an attribute. The persistence mechanism does
not recognize such changes automatically (as it does
for direct changes of a persistent object).
You must force the persistent object to be written to
the ZODB explicitly in this case.

-- 
Dieter


More information about the Zope mailing list