Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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-container
Commits
f4bc6d6f
Commit
f4bc6d6f
authored
Feb 19, 2014
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Naming cleanup
parent
bfbb147b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
src/zope/container/_proxy.py
src/zope/container/_proxy.py
+13
-14
src/zope/container/contained.py
src/zope/container/contained.py
+2
-2
No files found.
src/zope/container/_proxy.py
View file @
f4bc6d6f
...
...
@@ -13,7 +13,7 @@
##############################################################################
# This is very similar to the code in zope.proxy.__init__, but modified
#
not to have slots so that we can extend Persistent
#
to work properly when extending Persistent.
import
operator
import
sys
...
...
@@ -30,11 +30,10 @@ def _special_name(name):
return
(
name
.
startswith
(
'_Persistent'
)
or
name
.
startswith
(
'_p_'
)
or
name
.
startswith
(
'_v_'
)
or
name
in
PyProxyBase
.
__slots__
)
or
name
in
Py
Contained
ProxyBase
.
__slots__
)
class
PyProxyBase
(
Persistent
):
class
PyContainedProxyBase
(
Persistent
):
"""Persistent proxy
"""
__slots__
=
(
'_wrapped'
,
'__parent__'
,
'__name__'
)
...
...
@@ -140,17 +139,17 @@ class PyProxyBase(Persistent):
# Attribute protocol
def
__getattribute__
(
self
,
name
):
if
_special_name
(
name
):
return
super
(
PyProxyBase
,
self
).
__getattribute__
(
name
)
return
super
(
Py
Contained
ProxyBase
,
self
).
__getattribute__
(
name
)
if
name
in
(
'__reduce__'
,
'__reduce_ex__'
,
'__getstate__'
,
'__setstate__'
,
'__getnewargs__'
):
return
object
.
__getattribute__
(
self
,
name
)
# Only access this if we need it, otherwise persistence problems
if
name
==
'_wrapped'
:
return
super
(
PyProxyBase
,
self
).
__getattribute__
(
'_wrapped'
)
return
super
(
Py
Contained
ProxyBase
,
self
).
__getattribute__
(
'_wrapped'
)
try
:
mine
=
super
(
PyProxyBase
,
self
).
__getattribute__
(
name
)
mine
=
super
(
Py
Contained
ProxyBase
,
self
).
__getattribute__
(
name
)
except
AttributeError
:
mine
=
_MARKER
else
:
# pragma NO COVER PyPy
...
...
@@ -163,7 +162,7 @@ class PyProxyBase(Persistent):
return
mine
.
desc
.
__get__
(
self
)
try
:
try
:
wrapped
=
super
(
PyProxyBase
,
self
).
__getattribute__
(
'_wrapped'
)
wrapped
=
super
(
Py
Contained
ProxyBase
,
self
).
__getattribute__
(
'_wrapped'
)
except
KeyError
:
# During commit time of a persistent transaction, we can
# be in the state where we have an oid, but we are not actually
...
...
@@ -182,16 +181,16 @@ class PyProxyBase(Persistent):
def
__setattr__
(
self
,
name
,
value
):
if
_special_name
(
name
):
return
super
(
PyProxyBase
,
self
).
__setattr__
(
name
,
value
)
return
super
(
Py
Contained
ProxyBase
,
self
).
__setattr__
(
name
,
value
)
try
:
super
(
PyProxyBase
,
self
).
__getattribute__
(
name
)
super
(
Py
Contained
ProxyBase
,
self
).
__getattribute__
(
name
)
except
AttributeError
:
return
setattr
(
self
.
_wrapped
,
name
,
value
)
else
:
return
super
(
PyProxyBase
,
self
).
__setattr__
(
name
,
value
)
return
super
(
Py
Contained
ProxyBase
,
self
).
__setattr__
(
name
,
value
)
def
__delattr__
(
self
,
name
):
if
name
in
PyProxyBase
.
__slots__
:
if
name
in
Py
Contained
ProxyBase
.
__slots__
:
raise
AttributeError
()
delattr
(
self
.
_wrapped
,
name
)
...
...
@@ -439,13 +438,13 @@ class PyProxyBase(Persistent):
def
py_getProxiedObject
(
obj
):
if
isinstance
(
obj
,
PyProxyBase
):
if
isinstance
(
obj
,
Py
Contained
ProxyBase
):
return
obj
.
_wrapped
return
obj
def
py_setProxiedObject
(
obj
,
new_value
):
if
not
isinstance
(
obj
,
PyProxyBase
):
if
not
isinstance
(
obj
,
Py
Contained
ProxyBase
):
raise
TypeError
(
'Not a proxy'
)
old
,
obj
.
_wrapped
=
obj
.
_wrapped
,
new_value
return
old
src/zope/container/contained.py
View file @
f4bc6d6f
...
...
@@ -33,8 +33,8 @@ try:
from
zope.container._zope_container_contained
import
ContainedProxyBase
from
zope.container._zope_container_contained
import
getProxiedObject
except
ImportError
:
# PyPy
from
_proxy
import
py_getProxiedObject
as
getProxiedObject
from
_proxy
import
Py
ProxyBase
as
ContainedProxyBase
from
zope.container.
_proxy
import
py_getProxiedObject
as
getProxiedObject
from
zope.container._proxy
import
PyContained
ProxyBase
as
ContainedProxyBase
from
zope.lifecycleevent
import
ObjectMovedEvent
from
zope.lifecycleevent
import
ObjectAddedEvent
...
...
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