AW: [Zope-CMF] How to LOOK THROUGH acquisition?
Dan Fairs
monster at spiderplant.net
Wed Sep 1 08:37:57 EDT 2004
Hi,
>> How can I look througt acquisition process?
Sounds like you don't actually want the acquisition machinery to happen! :)
How about something like this (pseudo-code!)
s = getSiteRoot()
c = context
tracked_attrs = {}
while c != s:
v = getattr(aq_base(c), attr, None)
if not v is None:
tracked_attrs[c] = v # if you need v wrapped, then just
# use getattr rather than v
c = c.aq_parent
return tracked_attrs
That'll give you a dict keyed on the objects which have the attribute attr
you're looking for. If order is important to you (ie. where the object
with that attribute is in the acquisition path) then don't use a dict, or
key it on something else - use your imagination :)
Cheers,
Dan
More information about the Zope-CMF
mailing list