How to obtain the parent-object from an Zope-object
How can I obtain the 'parent' object in Zope with python (script)? I have a subfolder that contains some python script that I want to run on some selected objects from the parent folder (of this subfolder). I can go a level down by using object from self.objectValues(). But how do I go one level up? I cannot find this kind of information anywhere. Wim
On Fri, 16 May 2003 08:55:23 +0200 GMT (..8:55 where i live(GMT+2) ) Wim Bekker asked the Zope mailinglist about the following: WB> How can I obtain the 'parent' object in Zope with python (script)? myparent = object.aq_parent :) -- Geir Bækholt
On Friday 16 May 2003 10:33, Geir Bækholt wrote:
On Fri, 16 May 2003 08:55:23 +0200 GMT (..8:55 where i live(GMT+2) ) Wim Bekker asked the Zope mailinglist about the following:
WB> How can I obtain the 'parent' object in Zope with python (script)?
myparent = object.aq_parent
Hi, Maybe I'm wrong, but I've read here and there that the correct syntax should be : parent = object.aq_inner.aq_parent if you want to avoid acquisition problems... Thierry
Thierry FLORAC wrote at 2003-5-16 14:38 +0200:
On Friday 16 May 2003 10:33, Geir Bækholt wrote:
On Fri, 16 May 2003 08:55:23 +0200 GMT (..8:55 where i live(GMT+2) ) Wim Bekker asked the Zope mailinglist about the following:
WB> How can I obtain the 'parent' object in Zope with python (script)?
myparent = object.aq_parent
Hi,
Maybe I'm wrong, but I've read here and there that the correct syntax should be :
parent = object.aq_inner.aq_parent
"aq_inner" is protected, you cannot use it in TTW code. "getParentNode" (suggested by someone else) may work (though I am not sure). Dieter
I am afraid not. You will only be able to get at the URL parent, which may or may not be the same as the physical container. From OFS/ZDOM.py def getParentNode(self): """The parent of this node. All nodes except Document DocumentFragment and Attr may have a parent""" return getattr(self, 'aq_parent', None) Stefan On Freitag, Mai 16, 2003, at 22:10 Europe/Vienna, Dieter Maurer wrote:
Thierry FLORAC wrote at 2003-5-16 14:38 +0200:
On Friday 16 May 2003 10:33, Geir Bækholt wrote:
On Fri, 16 May 2003 08:55:23 +0200 GMT (..8:55 where i live(GMT+2) ) Wim Bekker asked the Zope mailinglist about the following:
WB> How can I obtain the 'parent' object in Zope with python (script)?
myparent = object.aq_parent
Hi,
Maybe I'm wrong, but I've read here and there that the correct syntax should be :
parent = object.aq_inner.aq_parent
"aq_inner" is protected, you cannot use it in TTW code.
"getParentNode" (suggested by someone else) may work (though I am not sure).
Dieter
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
Geir Bækholt wrote at 2003-5-16 10:33 +0200:
On Fri, 16 May 2003 08:55:23 +0200 GMT (..8:55 where i live(GMT+2) ) Wim Bekker asked the Zope mailinglist about the following:
WB> How can I obtain the 'parent' object in Zope with python (script)?
myparent = object.aq_parent
That usually works, but not always. It may fail, when the object was accessed via acquisition. The other proposal ("getParentNode") may be more reliable (as acquisition context might be cut away) but I am not sure (acquisition rules for a method's "self" are so complex that I always need to think for hours how they work in a concrete situation). Dieter
getParentNode() Stefan --On Freitag, 16. Mai 2003 08:55 +0200 Wim Bekker <wim@dv-rec.com> wrote:
How can I obtain the 'parent' object in Zope with python (script)?
I have a subfolder that contains some python script that I want to run on some selected objects from the parent folder (of this subfolder).
I can go a level down by using object from self.objectValues(). But how do I go one level up?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
participants (5)
-
Dieter Maurer -
Geir Bækholt -
Stefan H. Holek -
Thierry FLORAC -
Wim Bekker