[Zope-dev] Removing the acquisition wrapper from an object(Python script)

Dieter Maurer dieter@handshake.de
Sun, 4 Aug 2002 22:15:54 +0200


Adrian Hungate writes:
 > Why do you say it will not always work?
 > What situations might cause it not to work (Assuming that we already know
 > that the object is acquisition wrapped?)
You may want to read the "Acquisition" section of

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

You will learn that acquisition wrappers have two components: "aq_self"
and "aq_parent", and that an implicit acquisition wrapper first
asks "aq_self" and, if unsuccessful, automatically asks "aq_parent"
for an attribute lookup, while an explicit wrapper only asks "aq_self".

With these explanations you will understand that "hasattr(obj.aq_explicit,*)"
is equivalent to "hasattr(obj.aq_base,*)" iff "obj.aq_self" is not
itself acquisition wrapped.


Dieter