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
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
participants (2)
-
Dieter Maurer -
Wyatt Anderson