On 8/4/02 2:15 PM, "Dieter Maurer" <dieter@handshake.de> wrote:
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.
There is also the 'Acquisition' module, which is full of helpful functions that are preferred over going after attributes: Acquisition.aq_base(obj) It deals nicely with unwrapped objects in a cleaner way than the hasattr/getattr combos, and also introduces a powerful 'aq_acquire' function which can be used for fine control. It's documented in: http://www.zope.org//Members/michel/Projects/Interfaces/AcquisitionModuleInt erface -- Jeffrey P Shell www.cuemedia.com