[Zope] How to obtain the parent-object from an Zope-object

Stefan H. Holek stefan@epy.co.at
Sat, 17 May 2003 13:42:32 +0200


I am afraid not. You will only be able to get at the URL parent, which=20=

may or may not be the same as the physical container.

 =46rom 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=E6kholt 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=20
>>> (script)?
>>>
>>> myparent =3D object.aq_parent
>>
>>
>> Hi,
>>
>> Maybe I'm wrong, but I've read here and there that the correct syntax=20=

>> should
>> be :
>>
>>   parent =3D 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/