[Checkins] SVN: CMF/branches/philikon-aq/CMFCore/PortalObject.py Don't set __parent__ on self._components, set it on components.

Philipp von Weitershausen philikon at philikon.de
Sun Aug 26 18:43:58 EDT 2007


Log message for revision 79291:
  Don't set __parent__ on self._components, set it on components.
  What's the difference, they're the same object, you mgiht ask.
  Not quite. self._components has an acquisition wrapper around it.
  Setting __parent__ on an acquisition wrapper won't set the __parent__
  property on the original object (it will only relocate the wrapper's
  aq_parent).
  
  So, in short, always do aq_base(obj).__parent__ = ... if you want
  to set the __parent__ attribute of an object that inherits from
  one of the Acquisition base classes.
  

Changed:
  U   CMF/branches/philikon-aq/CMFCore/PortalObject.py

-=-
Modified: CMF/branches/philikon-aq/CMFCore/PortalObject.py
===================================================================
--- CMF/branches/philikon-aq/CMFCore/PortalObject.py	2007-08-26 22:41:20 UTC (rev 79290)
+++ CMF/branches/philikon-aq/CMFCore/PortalObject.py	2007-08-26 22:43:58 UTC (rev 79291)
@@ -67,8 +67,8 @@
             if next is None:
                 next = base
             name = '/'.join(self.getPhysicalPath())
-            self._components = PersistentComponents(name, (next,))
-            self._components.__parent__ = self
+            self._components = components = PersistentComponents(name, (next,))
+            components.__parent__ = self
         elif self._components.utilities.LookupClass \
                 != FiveVerifyingAdapterLookup:
             # BBB: for CMF 2.1 beta instances



More information about the Checkins mailing list