Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
fbe184fd
Commit
fbe184fd
authored
Jul 10, 2007
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge r71222 from old branch:
Allow assignment to a wrapper's __parent__.
parent
387924bb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
lib/python/Acquisition/_Acquisition.c
lib/python/Acquisition/_Acquisition.c
+2
-2
lib/python/Acquisition/tests.py
lib/python/Acquisition/tests.py
+15
-1
No files found.
lib/python/Acquisition/_Acquisition.c
View file @
fbe184fd
...
@@ -627,8 +627,8 @@ Wrapper_setattro(Wrapper *self, PyObject *oname, PyObject *v)
...
@@ -627,8 +627,8 @@ Wrapper_setattro(Wrapper *self, PyObject *oname, PyObject *v)
/* Allow assignment to parent, to change context. */
/* Allow assignment to parent, to change context. */
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
if
(
PyString_Check
(
oname
))
name
=
PyString_AS_STRING
(
oname
);
if
(
*
name
==
'a'
&&
name
[
1
]
==
'q'
&&
name
[
2
]
==
'_'
if
(
(
*
name
==
'a'
&&
name
[
1
]
==
'q'
&&
name
[
2
]
==
'_'
&&
strcmp
(
name
+
3
,
"parent"
)
==
0
)
&&
strcmp
(
name
+
3
,
"parent"
)
==
0
)
||
(
strcmp
(
name
,
"__parent__"
)
==
0
)
)
{
{
Py_XINCREF
(
v
);
Py_XINCREF
(
v
);
ASSIGN
(
self
->
container
,
v
);
ASSIGN
(
self
->
container
,
v
);
...
...
lib/python/Acquisition/tests.py
View file @
fbe184fd
...
@@ -1401,7 +1401,7 @@ def test_creating_wrappers_directly():
...
@@ -1401,7 +1401,7 @@ def test_creating_wrappers_directly():
...
...
TypeError: __init__() takes exactly 2 arguments (1 given)
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 = B()
>>> x.color = 'green'
>>> x.color = 'green'
...
@@ -1409,6 +1409,20 @@ def test_creating_wrappers_directly():
...
@@ -1409,6 +1409,20 @@ def test_creating_wrappers_directly():
>>> w.color
>>> w.color
'green'
'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()
>>> w = ImplicitAcquisitionWrapper()
Traceback (most recent call last):
Traceback (most recent call last):
...
...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment