[Product-Developers] safe way to get the parent of an object?

Luca Fabbri luca at keul.it
Thu Mar 22 17:02:40 UTC 2012

On Thu, Mar 22, 2012 at 5:53 PM, Maarten Nieber <maarten at usecm.com> wrote:
> Hi,
> I'm using obj.getParentNode() to get the parent of an object.
> However, I now read that this function returns obj.aq_parent, and that this is
> not guaranteed to always be correct.
> Apparently, the safe way is to use obj.aq_inner.aq_parent.

Seems that aq_parent((obj)) is faster (you need to import this
function from Acquisition module)

> Is this true? And is obj.aq_inner.aq_parent guaranteed to exist?

Of a Plone object: yes

-- luca

twitter: http://twitter.com/keul
linkedin: http://linkedin.com/in/lucafbb
blog: http://blog.keul.it/

More information about the Product-Developers mailing list