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
aedd241c
Commit
aedd241c
authored
Nov 21, 2006
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Step 4: Make aq_get aware of __parent__ pointers.
(Also some comment cosmetics in _Acquisition.c)
parent
398463fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
14 deletions
+81
-14
_Acquisition.c
_Acquisition.c
+29
-8
tests.py
tests.py
+52
-6
No files found.
_Acquisition.c
View file @
aedd241c
...
...
@@ -1391,9 +1391,8 @@ capi_aq_acquire(PyObject *self, PyObject *name, PyObject *filter,
explicit
||
WRAPPER
(
self
)
->
ob_type
==
(
PyTypeObject
*
)
&
Wrappertype
,
explicit
,
containment
);
/* Not wrapped; check if we have a __parent__ pointer. If that's
the case, we create a wrapper and pretend it's business as
usual */
/* Not wrapped; check if we have a __parent__ pointer. In that
case, create a wrapper and pretend it's business as usual */
else
if
((
result
=
PyObject_GetAttr
(
self
,
py__parent__
)))
{
self
=
newWrapper
(
self
,
result
,
(
PyTypeObject
*
)
&
Wrappertype
);
...
...
@@ -1408,8 +1407,8 @@ capi_aq_acquire(PyObject *self, PyObject *name, PyObject *filter,
/* No filter, and no __parent__, so just getattr */
else
{
/*
we need to clean up the AttributeError from the previous
getattr
(because it has clearly failed) */
/*
clean up the AttributeError from the previous getattr
(because it has clearly failed) */
PyErr_Fetch
(
&
result
,
&
v
,
&
tb
);
if
(
result
&&
(
result
!=
PyExc_AttributeError
))
{
...
...
@@ -1457,13 +1456,35 @@ module_aq_acquire(PyObject *ignored, PyObject *args, PyObject *kw)
static
PyObject
*
capi_aq_get
(
PyObject
*
self
,
PyObject
*
name
,
PyObject
*
defalt
,
int
containment
)
{
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
,
*
v
,
*
tb
;
/* We got a wrapped object, so business as usual */
if
(
isWrapper
(
self
))
result
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
0
,
0
,
OBJECT
(
self
),
1
,
1
,
1
,
containment
);
/* Not wrapped; check if we have a __parent__ pointer. In that
case, create a wrapper and pretend it's business as usual */
else
if
((
result
=
PyObject_GetAttr
(
self
,
py__parent__
)))
{
self
=
newWrapper
(
self
,
result
,
(
PyTypeObject
*
)
&
Wrappertype
);
Py_DECREF
(
result
);
/* don't need __parent__ anymore */
result
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
0
,
0
,
OBJECT
(
self
),
1
,
1
,
1
,
containment
);
Py_DECREF
(
self
);
/* get rid of temp wrapper */
}
else
{
/* clean up the AttributeError from the previous getattr
(because it has clearly failed) */
PyErr_Fetch
(
&
result
,
&
v
,
&
tb
);
if
(
result
&&
(
result
!=
PyExc_AttributeError
))
{
PyErr_Restore
(
result
,
v
,
tb
);
return
NULL
;
}
Py_XDECREF
(
result
);
Py_XDECREF
(
v
);
Py_XDECREF
(
tb
);
result
=
PyObject_GetAttr
(
self
,
name
);
}
if
(
!
result
&&
defalt
)
{
...
...
tests.py
View file @
aedd241c
...
...
@@ -1688,7 +1688,8 @@ def test___parent__no_wrappers():
>>> z.foo = 43 # this should not be found
>>> z.bar = 3.145
``aq_acquire`` works we know it from implicit/acquisition wrappers:
``aq_acquire`` works as we know it from implicit/acquisition
wrappers:
>>> Acquisition.aq_acquire(x, 'hello')
'world'
...
...
@@ -1697,7 +1698,16 @@ def test___parent__no_wrappers():
>>> Acquisition.aq_acquire(x, 'bar')
3.145
as does ``aq_parent``:
as does ``aq_get``:
>>> Acquisition.aq_get(x, 'hello')
'world'
>>> Acquisition.aq_get(x, 'foo')
42
>>> Acquisition.aq_get(x, 'bar')
3.145
and ``aq_parent``:
>>> Acquisition.aq_parent(x) is y
True
...
...
@@ -1741,7 +1751,16 @@ def test_implicit_wrapper_as___parent__():
>>> Acquisition.aq_acquire(x, 'bar')
3.145
as does ``aq_parent``:
as does ``aq_get``:
>>> Acquisition.aq_get(x, 'hello')
'world'
>>> Acquisition.aq_get(x, 'foo')
42
>>> Acquisition.aq_get(x, 'bar')
3.145
and ``aq_parent``:
>>> Acquisition.aq_parent(x) is y
True
...
...
@@ -1808,7 +1827,16 @@ def test_explicit_wrapper_as___parent__():
>>> Acquisition.aq_acquire(x, 'bar')
3.145
as does ``aq_parent``:
as does ``aq_get``:
>>> Acquisition.aq_get(x, 'hello')
'world'
>>> Acquisition.aq_get(x, 'foo')
42
>>> Acquisition.aq_get(x, 'bar')
3.145
and ``aq_parent``:
>>> Acquisition.aq_parent(x) is y
True
...
...
@@ -1869,7 +1897,16 @@ def test_implicit_wrapper_has_nonwrapper_as_aq_parent():
>>> Acquisition.aq_acquire(x, 'bar')
3.145
as does ``aq_parent``:
as does ``aq_get``:
>>> Acquisition.aq_get(x, 'hello')
'world'
>>> Acquisition.aq_get(x, 'foo')
42
>>> Acquisition.aq_get(x, 'bar')
3.145
and ``aq_parent``:
>>> Acquisition.aq_parent(x) == y
True
...
...
@@ -1915,7 +1952,16 @@ def test_explicit_wrapper_has_nonwrapper_as_aq_parent():
>>> Acquisition.aq_acquire(x, 'bar')
3.145
as does ``aq_parent``:
as does ``aq_get``:
>>> Acquisition.aq_get(x, 'hello')
'world'
>>> Acquisition.aq_get(x, 'foo')
42
>>> Acquisition.aq_get(x, 'bar')
3.145
and ``aq_parent``:
>>> Acquisition.aq_parent(x) == y
True
...
...
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