[Zope] Re: Getting a methods parent (in a product)
Jens Vagelpohl
jens at dataflake.org
Sat Jul 23 11:21:33 EDT 2005
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.
jens
More information about the Zope
mailing list