[Zope3-Users] OOBTree instances lose attributes upon restart
Marius Gedminas
mgedmin at b4net.lt
Fri Apr 6 04:41:40 EDT 2007
On Fri, Apr 06, 2007 at 12:53:06AM -0700, Douglas Douglas wrote:
> Here's my class definition:
>
> class Variable(OOBTree, Contained):
>
> implements(IVariable, IAttributeAnnotatable)
>
> name = None
> units = None
>
> I start the server and everything works like a charm. My AddForm works OK for
> the Variable class. I checked its create() method (with assert statements) and
> the returned instances contain the name and units attributes set from the form.
>
> But if I stop the server and restart later, my data (datetimes and floats) are
> still there, but my name and units attributes are None!!
OOBTree is at fault here. I'm sure that if you investigated it, you'd
find a custom __getstate__.
I suggest that you do not subclass OOBTree but instead contain it in an
attribute and delegate all the methods.
class Variable(Persistent, Contained):
implements(...)
def __init__(self):
self.data = OOBTree()
def __getitem__(self, key):
return self.data[key]
...
Marius Gedminas
--
I dont know about madness (and anyway, the little green martians dancing
around me tell me not to worry...), but I've implemented something not
unlike this just now.
-- Peter Sabaini
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070406/413c0280/attachment.bin
More information about the Zope3-users
mailing list