[Zope] accessing PARENTS from python???

Kapil Thangavelu kthangavelu@earthlink.net
Sun, 13 Aug 2000 05:50:12 -0700


Kevin Howe wrote:
> 
> I am trying to access the PARENT of an object in a python class of mine.
> I want to use the absolute_url() of the parent in a variable.
> 
> I though it could be done the following way, but got an error:
> 
>      parent=self.PARENTS[0]
>      aurl = parent.absolute_url()
> 
> I then tried using REQUEST. It works, but doesn't give the correct
> information. Instead of giving me the parent  of the current object(self),
> it gives the parent of the DTML page in which the object was called.
> 
>      parent=self.REQUEST.PARENTS[0]
>      aurl = parent.absolute_url()
> 
> How do you resolve the PARENT object of an object?

you might want to try an alternative method using acquisition

aurl = self.aq_parent.absolute_url()

Kapil