[Zope] persistent object with non-persistent attributes
Tue, 4 Mar 2003 09:30:53 +0000
On Tuesday 04 March 2003 9:22 am, Jerome Alet wrote:
> I would like to create a python Zope product which allows me
> to create persistent objects.
> but these objects have (as subobjects ?) complex attributes which
> are themselves instances of a non-Zope related class, and which
> should not be persistent (think hardware plug&play), because
> they are recreated every time a method is called on my instance.
Zope uses (by default) four publishing threads. That means you will get four
copies of your objects in memory at any one time (or 8, if you have 2 zeo
clients). You also have the possibility of ZODB choosing to deactivate your
object, so all attributes are lost from all 4 of those objects.
'hardware plug&play' makes me think this is this what you want... Perhaps
storing this special object in a module-level global would be better?
> myZopePersistentClassInstance.complexAttr = myNonZopeClass()
> but this will probably, if it works, bloat by ZODB.
> is there a way to do this without suffering from severe bloat ?
myZopePersistentClassInstance._v_complexAttr = myNonZopeClass()
will exclude that attribute from ZODB processing.