[Zope] Problems accessing container properties at productcreation time

zope at netchan.cotse.net zope at netchan.cotse.net
Tue Apr 6 16:43:10 EDT 2004


> Thanks for the tip, Robert.
> I did also notice that if I did the following (right after 
> _setObject()):
> 
>   ob = container._getOb(id)
> 
> and worked with the "ob" handle, I could access properties
> in the container. I can't say I understand why :(

Because this latter is the "wrapped" version of your object in the terms
of aquisition. You can use __of__ to achive the same result.

> I have similar problems referencing
> methods/properties of MyFolder from within the methods of MyObject at
> the time of creation.

Oh, this is a nice one. If you have a newly created object, and you want
to store references pointing to other zodb objects in it, you always
have to do that with the wrapped version, e.g. either in
manage_afterAdd, or from the container. You can't do that in __init__.
This bit me once because sometimes it still works and gives very strange
results when you try to debug.

Regards,
Sandor




More information about the Zope mailing list