[Zope] acquisition and __bobo_traverse__
Dylan Reinhardt
zope at dylanreinhardt.com
Tue Jan 20 10:53:47 EST 2004
On Tue, 2004-01-20 at 03:36, Chris Withers wrote:
[snip]
> > All with no joy... in each case, the method is the correct method but
> > names are resolved by the *calling* object, not by the returned method's
> > container.
> try:
>
> aq_base(obj.method).__of__(aq_base(self))
That didn't do it, but it did prompt me to go re-read "Acquisition
Algebra" which is always a good time. :-)
It seems like what I want is exactly what aq_inner() is supposed to
do... return an object wrapped by containment only. But for some reason
it's still not working with any combination of aq_base and/or aq_inner.
Anyway, I settled on a workaround for now... for methods I'm going to
wrap this way, I stuff the name of the container into
REQUEST['traverse_from'] and add this code to the aliased methods:
<dtml-if traverse_from>
<dtml-call "REQUEST.set('me', restrictedTraverse(traverse_from))">
<dtml-else>
<dtml-call "REQUEST.set('me', this())">
</dtml-if>
And then call everything from the "me" object, ex:
<dtml-var "me.getId()">
Seems to work fine, though I'm sure it's not as efficient as it could
be.
Thanks for your help.
Dylan
More information about the Zope
mailing list