Michael Howitz wrote:
Am Mittwoch, den 05.04.2006, 09:36 -0500 schrieb Jeff Rush:
I know that Zope3 dropped 'implicit' acquisition, but is there any support for
*explicit* acquisition that walks the __parent__ containment hierarchy.
Something that follows the same rules as traverse() to look up a name, but
from bottom-to-top instead of traverse() from top-to-bottom?
for a project we wrote the following function. It climbes up the
conatinment hierachy until it finds an object which implements the given
<snip function source>
Thanks Michael for the function. It seems very useful and I'll add it to my
Jürgen made me aware of the ++acquire++NAME pathing and I've come up with a
solution using that approach.
I have three levels of containers; ventures, ledgers, entries.
When producing views of ledgers, I wanted to be able to display the venture's
name, "context/venture/legalname", and when displaying a ledger entry, the
ledger's description, "context/ledger/desc".
By adding to my venture class,
And to the ledger class,
I am now able to do things like:
<span tal:content="context/++acquire++venture/legalname" />
<span tal:content="context/++acquire++/ledger/desc" />
It might be interesting to add your function as a namespace, and do:
<span tal:content="context/++interface++IVenture/legalname" />
Your approach is more general, not requiring the building in of support for
"return self" in each container class.
Zope3-users mailing list