Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Acquisition
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
Acquisition
Commits
12c55848
Commit
12c55848
authored
Nov 21, 2006
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Step 5: Make aq_chain aware of __parent__ pointers.
parent
69758b07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
11 deletions
+49
-11
_Acquisition.c
_Acquisition.c
+22
-3
tests.py
tests.py
+27
-8
No files found.
_Acquisition.c
View file @
12c55848
...
...
@@ -1650,7 +1650,7 @@ module_aq_inner(PyObject *ignored, PyObject *args)
static
PyObject
*
capi_aq_chain
(
PyObject
*
self
,
int
containment
)
{
PyObject
*
result
;
PyObject
*
result
,
*
v
,
*
tb
;
UNLESS
(
result
=
PyList_New
(
0
))
return
NULL
;
...
...
@@ -1673,8 +1673,27 @@ capi_aq_chain(PyObject *self, int containment)
}
}
else
if
(
PyList_Append
(
result
,
self
)
<
0
)
goto
err
;
{
if
(
PyList_Append
(
result
,
self
)
<
0
)
goto
err
;
if
((
self
=
PyObject_GetAttr
(
self
,
py__parent__
)))
{
Py_DECREF
(
self
);
/* don't need our own reference */
if
(
self
!=
Py_None
)
continue
;
}
else
{
PyErr_Fetch
(
&
self
,
&
v
,
&
tb
);
if
(
self
&&
(
self
!=
PyExc_AttributeError
))
{
PyErr_Restore
(
self
,
v
,
tb
);
return
NULL
;
}
Py_XDECREF
(
self
);
Py_XDECREF
(
v
);
Py_XDECREF
(
tb
);
}
}
break
;
}
...
...
tests.py
View file @
12c55848
...
...
@@ -1714,7 +1714,10 @@ def test___parent__no_wrappers():
>>> Acquisition.aq_parent(y) is z
True
TODO aq_chain
as well as ``aq_chain``:
>>> Acquisition.aq_chain(x) == [x, y, z]
True
"""
def
test_implicit_wrapper_as___parent__
():
...
...
@@ -1767,6 +1770,11 @@ def test_implicit_wrapper_as___parent__():
>>> Acquisition.aq_parent(y) is z
True
as well as ``aq_chain``:
>>> Acquisition.aq_chain(x) == [x, y, z]
True
Note that also the (implicit) acquisition wrapper has a __parent__
pointer, which is automatically computed from the acquisition
container (it's identical to aq_parent):
...
...
@@ -1791,8 +1799,6 @@ def test_implicit_wrapper_as___parent__():
Traceback (most recent call last):
...
AttributeError: __parent__
TODO aq_chain
"""
def
test_explicit_wrapper_as___parent__
():
...
...
@@ -1843,6 +1849,11 @@ def test_explicit_wrapper_as___parent__():
>>> Acquisition.aq_parent(y) is z
True
as well as ``aq_chain``:
>>> Acquisition.aq_chain(x) == [x, y, z]
True
Note that also the (explicit) acquisition wrapper has a __parent__
pointer, which is automatically computed from the acquisition
container (it's identical to aq_parent):
...
...
@@ -1867,8 +1878,6 @@ def test_explicit_wrapper_as___parent__():
Traceback (most recent call last):
...
AttributeError: __parent__
TODO aq_chain
"""
def
test_implicit_wrapper_has_nonwrapper_as_aq_parent
():
...
...
@@ -1917,6 +1926,13 @@ def test_implicit_wrapper_has_nonwrapper_as_aq_parent():
>>> Acquisition.aq_parent(y) is z
True
as well as ``aq_chain``:
>>> Acquisition.aq_chain(x) == [x, y, z]
True
>>> x.aq_chain == [x, y, z]
True
Because the outmost object, ``x``, is wrapped in an implicit
acquisition wrapper, we can also use direct attribute access:
...
...
@@ -1926,8 +1942,6 @@ def test_implicit_wrapper_has_nonwrapper_as_aq_parent():
42
>>> x.bar
3.145
TODO aq_chain
"""
def
test_explicit_wrapper_has_nonwrapper_as_aq_parent
():
...
...
@@ -1976,7 +1990,12 @@ def test_explicit_wrapper_has_nonwrapper_as_aq_parent():
>>> Acquisition.aq_parent(y) is z
True
TODO aq_chain
as well as ``aq_chain``:
>>> Acquisition.aq_chain(x) == [x, y, z]
True
>>> x.aq_chain == [x, y, z]
True
"""
import
unittest
...
...
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