[Zope-dev] __getattr__ and Acquisition

Dieter Maurer dieter@handshake.de
Mon, 23 Sep 2002 19:52:58 +0200


Andreas Kostyrka writes:
 > I've just discovered, that Acquisition does not work with __getattr__,
 > right?
It does, just not the way, you expect it:

  The actual attribute lookup (for attributes not starting with
  "aq_") is always made with an unwrapped object.
  That's the reason why the "self" in "getattr" is unwrapped.

  Special operations ensure for Python Methods (the one of
  "ExtensionClass" not Zope's!) that their "self" receives part
  of the acquisition context (it's rarely the full context,
  just enough to work in most cases).
  They are rebuild with the current node as "self", when the recursive lookup
  comes back out of "aq_self" iff the method's "self" is "aq_self".

You may have a look at my "Reference" product

  <http://www.dieter.handshake.de/pyprojects/zope>

There, I fight with the peculiarities of "__getattr__" and
acquisition context for methods.


Dieter