[Zope-Checkins]
SVN: Zope/branches/philikon-aq/lib/python/Acquisition/
Merge r71222 from old branch:
Philipp von Weitershausen
philikon at philikon.de
Tue Jul 10 11:58:32 EDT 2007
Log message for revision 77681:
Merge r71222 from old branch:
Allow assignment to a wrapper's __parent__.
Changed:
U Zope/branches/philikon-aq/lib/python/Acquisition/_Acquisition.c
U Zope/branches/philikon-aq/lib/python/Acquisition/tests.py
-=-
Modified: Zope/branches/philikon-aq/lib/python/Acquisition/_Acquisition.c
===================================================================
--- Zope/branches/philikon-aq/lib/python/Acquisition/_Acquisition.c 2007-07-10 15:49:42 UTC (rev 77680)
+++ Zope/branches/philikon-aq/lib/python/Acquisition/_Acquisition.c 2007-07-10 15:58:32 UTC (rev 77681)
@@ -627,8 +627,8 @@
/* Allow assignment to parent, to change context. */
if (PyString_Check(oname)) name=PyString_AS_STRING(oname);
- if (*name=='a' && name[1]=='q' && name[2]=='_'
- && strcmp(name+3,"parent")==0)
+ if ((*name=='a' && name[1]=='q' && name[2]=='_'
+ && strcmp(name+3,"parent")==0) || (strcmp(name, "__parent__")==0))
{
Py_XINCREF(v);
ASSIGN(self->container, v);
Modified: Zope/branches/philikon-aq/lib/python/Acquisition/tests.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Acquisition/tests.py 2007-07-10 15:49:42 UTC (rev 77680)
+++ Zope/branches/philikon-aq/lib/python/Acquisition/tests.py 2007-07-10 15:58:32 UTC (rev 77681)
@@ -1401,7 +1401,7 @@
...
TypeError: __init__() takes exactly 2 arguments (1 given)
- We can reassign aq_parent
+ We can reassign aq_parent / __parent__ on a wrapper:
>>> x = B()
>>> x.color = 'green'
@@ -1409,6 +1409,20 @@
>>> w.color
'green'
+ >>> y = B()
+ >>> y.color = 'blue'
+ >>> w.__parent__ = y
+ >>> w.color
+ 'blue'
+
+ Note that messing with the wrapper won't in any way affect the
+ wrapped object:
+
+ >>> Acquisition.aq_base(w).__parent__
+ Traceback (most recent call last):
+ ...
+ AttributeError: __parent__
+
>>> w = ImplicitAcquisitionWrapper()
Traceback (most recent call last):
...
More information about the Zope-Checkins
mailing list