[Zope-dev] Explicit Acquisition within Acquistion.Implicit derived class

Dieter Maurer dieter at handshake.de
Tue May 25 14:17:23 EDT 2004


Wyatt Anderson wrote at 2004-5-24 13:01 -0400:
> ....
>In a Python Product class, named TestAcquisition, I derive
>from Folder (which in turn gives me Acquistion.Implicit).  This
>class defines an attribute which can dynamically be set to
>be acquired from nested TestAcquisition objects.  In order to
>do this I test whether the attribute can be acquired (by checking
>to see if aq_parent has the attribute).  In the top-level
>TestAcquisition object, this attribute should not be acquirable,
>and thus it will set it
>
>self.attribute = 1
>
>In sub-objects of TestAcquisition, by default the attribute will
>be acquired (which I test and do in manage_afterAdd) by setting
>
>self.aq_explicit.attribute = Attribute.Acquired

Acquisition (and explicit acquisition) works differently from
what you expect.

If you have an acquisition wrapped "obj", then "obj.aq_explicit"
rewraps "obj" into an explicit acquisition wrapper.

"self.aq_explicit.XXX = ..."
has the same effect as "self.XXX = ..."
as assignment *always* effects the base object.

Only lookup works differently for implicit and explicit
acquisition wrappers.

-- 
Dieter



More information about the Zope-Dev mailing list