[Zope-dev] How to aquire from Context?
Dieter Maurer
dieter@handshake.de
Sun, 17 Jun 2001 21:23:22 +0200 (CEST)
Matt Hamilton writes:
> ....
> According to the ZDG (Great read,
> thanks guys!):
>
> -- snip --
>
> (Acquisition works by: ) Containment Before Context
> ....
>
> Now that makes perfect sense to me and I can see why it happens as
> such. However what if I want (Context Before Containment).
I fear, there is no simple solution.
You can follow the context chain with 'aq_parent'.
Thus, you can implement your own lookup. However,
you will need an external method 'hasItself' to
check, when you found the binding you are looking for.
def hasItself(object,attr):
object= getattr(object,'aq_base',object)
return hasattr(object,attr)
Dieter