[Zope] Set "uncontained" attributes on a Implicitly wrapped object.

Dieter Maurer dieter@handshake.de
Fri, 18 Jul 2003 21:12:26 +0200


Johan Carlsson wrote at 2003-7-17 18:36 +0200:
 > ...
 > I need to save a referens to a acquision wrapped object "Configure"
 > in a object which at some point doesn't have it's own context (just a 
 > single wrapped object).
 > ...
 > Just assigning it to the attribute self._v_skinfolder=sf and the 
 > accessing it as self.skinfolder makes it contained in the object
 > (aq_chain would say [<Skinfolder>, <Object>])

This is not the case:

  Only if an object is unwrapped, is the
  container of "AcquisitionWrapper(object,parent)" determined by
  "parent".
  Otherwise, its container is the container of object.

To say it differently:
  The container of an acquisition wrapped
  object "o" is "o.aq_inner.aq_parent".

  If "o" is "AcquistionWrapper(self,parent)" with "self" unwrapped,
  then "o.aq_inner" is "o". Otherwise, "o.aq_inner" is "self.aq_inner".

 > ...
 > Is there anyway to make uncontained attributes of an object
 > that inherits Acquisision.Implicit?

No, if the container is an "ExtensionClass" instance.
Any "ExtensionClass" attribute lookup checks whether the
looked up object has an "__of__" method and calls it in this case.

The usual way to avoid this mechanism is to access the attribute
via "self.__dict__['attribute']".


Dieter