[Zope] acquisition problem
Dieter Maurer
dieter@handshake.de
Fri, 29 Jun 2001 20:41:06 +0200 (CEST)
kosh@aesaeion.com writes:
> DTML documents look at where the document is physically located while
> methods look around where they currently appear to be located. I need my
> document to look in itself and then look around like a method does.
> Methods act locally at any folder they inherit to and I need my doc to act
> the same way.
Did you try it and it did not work?
As I understand it now, a DTML document does (almost) precisely
what you want:
It pushes "self.aq_explicit" onto the namespace stack.
This means, it looks into itself (its properties and
methods). It normally should not look into its physical parents
because of the "aq_explicit". The "aq_explicit" disables
automatic lookup of names in the "aq_parent".
I know, that this method works only as you want it,
when the DTML document is called directly from ZPublisher.
If called indirectly, the document's parents are
part of "aq_self" and not "aq_parent". Thus,
"aq_explicit" does not prevent lookup there.
If you are ready to use an external method for these
indirect accesses, you can unwrap the document:
def unwrapContext(obj):
return getattr(obj,'aq_inner',obj)
You use the result of this call as variant of the document
for indirect calls.
Dieter