[Zope] FW: Explicit Acquisition within Acquistion.Implicit derived
class
Wyatt Anderson
wyatt95 at hotmail.com
Tue May 25 12:42:52 EDT 2004
Anyone familiar with Acquisition specifics in an Acquisition.Implicit
Object? I want to be able to dynamically set an attribute (it does
Start with an '_' (underscore)) to a value or to explicity say to
acquire it from its ancestors.
Thanks.
Wyatt
-----Original Message-----
From: Wyatt Anderson [mailto:wyatt95 at hotmail.com]
Sent: Monday, May 24, 2004 1:42 PM
To: 'Wyatt Anderson'; 'zope-dev at zope.org'
Subject: RE: Explicit Acquisition within Acquistion.Implicit derived
class
After further review, this strange behavior can happen simply after
viewing the object a couple times. It seems erratic at best and
obviously is not the behavior I'm after. What am I missing about
explicit acquisition? From the Zope Developer's Guide:
-------------
Sometimes, you want to dynamically make an implicitly acquiring object
acquire explicitly. You can do this by getting the object's aq_explicit
attribute. This attribute provides the object with an explicit wrapper
that places the original implicit wrapper.
-------------
Unfortunately, that's all that is said about aq_explicit.
-----Original Message-----
From: Wyatt Anderson [mailto:wyatt95 at hotmail.com]
Sent: Monday, May 24, 2004 1:01 PM
To: 'zope-dev at zope.org'
Subject: Explicit Acquisition within Acquistion.Implicit derived class
Hello,
I am encountering strange behavior when trying to dynamically
set explicit Acquisition within an Acquisition.Implicit object.
The strangeness seems to happen when I refresh the product only,
but I do not feel certain of this which has me a little nervous.
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
I can dynamically unset and set sub-objects acquisition of this
attribute simply by setting
self.attribute = 2
or
self.aq_explicit.attribute = Attribute.Acquired
within the TestAcquistion sub-object. This seems to be working
as desired until I refresh the Product, even just simply adding
a pdb.set_trace() as the only change. After the refresh all
the subobjects that had explicitly been set to acquire the attribute
all return the Special Acquisition Object (Acquisition.Acquired) instead
of the desired value to be acquired.
Is this a bug, something I just have to live with, or am I missing
something on acquisition in my product? I'd really like to keep the
implicit acquisition and not switch to Acquisition.Explicit.
Thanks in advance!
Wyatt
More information about the Zope
mailing list