On 23 Jul 2005, at 16:12, Peter Bengtsson wrote:
from Acquisition import aq_inner, aq_parent

parent = aq_parent(aq_inner(self))

This will return the true container the instance is set in, not just
the acquisition parent.

What's so bad about
parent = self.aq_parent

Two things:

- simply using aq_parent does not guarantee giving you the real containment parent. Depending on the path used to access the object it could be something different from the true containment parent. That's the power of acquisition...

- direct attribute access like that makes me feel dirty. I prefer the true object-oriented style where you use methods to get at stuff.


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to