Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope.proxy
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
Boxiang Sun
zope.proxy
Commits
ba4bc440
Commit
ba4bc440
authored
Jun 06, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pure-Python fallback implementations of the proxy module API functions.
parent
f3fa479f
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
284 additions
and
87 deletions
+284
-87
CHANGES.txt
CHANGES.txt
+2
-1
src/zope/proxy/__init__.py
src/zope/proxy/__init__.py
+72
-12
src/zope/proxy/tests/test_proxy.py
src/zope/proxy/tests/test_proxy.py
+210
-74
No files found.
CHANGES.txt
View file @
ba4bc440
...
...
@@ -5,7 +5,8 @@ CHANGES
4.0.0 (unreleased)
------------------
- Added a pure-Python fallback implementation of ``zope.proxy.ProxyBase``.
- Added a pure-Python fallback implementations of ``zope.proxy.ProxyBase``
and the proxy module API functions.
- Added support for continuous integration using ``tox`` and ``jenkins``.
...
...
src/zope/proxy/__init__.py
View file @
ba4bc440
...
...
@@ -339,15 +339,75 @@ class PyProxyBase(object):
self
.
_wrapped
=
pow
(
self
.
_wrapped
,
other
,
modulus
)
return
self
# Python API: not used in this module
from
zope.proxy._zope_proxy_proxy
import
ProxyBase
from
zope.proxy._zope_proxy_proxy
import
getProxiedObject
from
zope.proxy._zope_proxy_proxy
import
setProxiedObject
from
zope.proxy._zope_proxy_proxy
import
isProxy
from
zope.proxy._zope_proxy_proxy
import
sameProxiedObjects
from
zope.proxy._zope_proxy_proxy
import
queryProxy
from
zope.proxy._zope_proxy_proxy
import
queryInnerProxy
from
zope.proxy._zope_proxy_proxy
import
removeAllProxies
# API for proxy-using C extensions.
from
zope.proxy._zope_proxy_proxy
import
_CAPI
def
py_getProxiedObject
(
obj
):
if
isinstance
(
obj
,
PyProxyBase
):
return
obj
.
_wrapped
return
obj
def
py_setProxiedObject
(
obj
,
new_value
):
if
not
isinstance
(
obj
,
PyProxyBase
):
raise
TypeError
(
'Not a proxy'
)
old
,
obj
.
_wrapped
=
obj
.
_wrapped
,
new_value
return
old
def
py_isProxy
(
obj
,
klass
=
None
):
if
klass
is
None
:
klass
=
PyProxyBase
return
isinstance
(
obj
,
klass
)
def
py_sameProxiedObjects
(
lhs
,
rhs
):
while
isinstance
(
lhs
,
PyProxyBase
):
lhs
=
lhs
.
_wrapped
while
isinstance
(
rhs
,
PyProxyBase
):
rhs
=
rhs
.
_wrapped
return
lhs
is
rhs
def
py_queryProxy
(
obj
,
klass
=
None
,
default
=
None
):
if
klass
is
None
:
klass
=
PyProxyBase
while
obj
is
not
None
and
not
isinstance
(
obj
,
klass
):
obj
=
getattr
(
obj
,
'_wrapped'
,
None
)
if
obj
is
not
None
:
return
obj
return
default
def
py_queryInnerProxy
(
obj
,
klass
=
None
,
default
=
None
):
if
klass
is
None
:
klass
=
PyProxyBase
found
=
[]
while
obj
is
not
None
:
if
isinstance
(
obj
,
klass
):
found
.
append
(
obj
)
# stack
obj
=
getattr
(
obj
,
'_wrapped'
,
None
)
if
found
:
return
found
[
-
1
]
return
default
def
py_removeAllProxies
(
obj
):
while
isinstance
(
obj
,
PyProxyBase
):
obj
=
obj
.
_wrapped
return
obj
try
:
# Python API: not used in this module
from
zope.proxy._zope_proxy_proxy
import
ProxyBase
from
zope.proxy._zope_proxy_proxy
import
getProxiedObject
from
zope.proxy._zope_proxy_proxy
import
setProxiedObject
from
zope.proxy._zope_proxy_proxy
import
isProxy
from
zope.proxy._zope_proxy_proxy
import
sameProxiedObjects
from
zope.proxy._zope_proxy_proxy
import
queryProxy
from
zope.proxy._zope_proxy_proxy
import
queryInnerProxy
from
zope.proxy._zope_proxy_proxy
import
removeAllProxies
# API for proxy-using C extensions.
from
zope.proxy._zope_proxy_proxy
import
_CAPI
except
ImportError
:
#pragma NO COVER
# no C extension available, fall back
ProxyBase
=
PyProxyBase
getProxiedObject
=
py_getProxiedObject
setProxiedObject
=
py_setProxiedObject
isProxy
=
py_isProxy
sameProxiedObjects
=
py_sameProxiedObjects
queryProxy
=
py_queryProxy
queryInnerProxy
=
py_queryInnerProxy
removeAllProxies
=
py_removeAllProxies
src/zope/proxy/tests/test_proxy.py
View file @
ba4bc440
This diff is collapsed.
Click to expand it.
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