Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
persistent
Commits
69d60dc2
Commit
69d60dc2
authored
Apr 08, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for changing the _p_ attributes of broken objects; fix it for _p_changed in pure-python.
parent
5efcab76
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
.gitignore
.gitignore
+1
-0
persistent/persistence.py
persistent/persistence.py
+5
-2
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+22
-0
No files found.
.gitignore
View file @
69d60dc2
...
@@ -13,3 +13,4 @@ nosetests.xml
...
@@ -13,3 +13,4 @@ nosetests.xml
coverage.xml
coverage.xml
*.egg-info
*.egg-info
.installed.cfg
.installed.cfg
.dir-locals.el
persistent/persistence.py
View file @
69d60dc2
...
@@ -409,9 +409,12 @@ class Persistent(object):
...
@@ -409,9 +409,12 @@ class Persistent(object):
after
=
self
.
__flags
|
_CHANGED
after
=
self
.
__flags
|
_CHANGED
if
before
!=
after
:
if
before
!=
after
:
self
.
_p_register
()
self
.
_p_register
()
self
.
__flags
=
after
_OSA
(
self
,
'_Persistent__flags'
,
after
)
else
:
else
:
self
.
__flags
&=
~
_CHANGED
flags
=
self
.
__flags
flags
&=
~
_CHANGED
_OSA
(
self
,
'_Persistent__flags'
,
flags
)
def
_p_accessed
(
self
):
def
_p_accessed
(
self
):
# Notify the jar's pickle cache that we have been accessed.
# Notify the jar's pickle cache that we have been accessed.
...
...
persistent/tests/test_persistence.py
View file @
69d60dc2
...
@@ -1381,6 +1381,28 @@ class _Persistent_Base(object):
...
@@ -1381,6 +1381,28 @@ class _Persistent_Base(object):
inst
=
subclass
()
inst
=
subclass
()
self
.
assertEqual
(
object
.
__getattribute__
(
inst
,
'_v_setattr_called'
),
False
)
self
.
assertEqual
(
object
.
__getattribute__
(
inst
,
'_v_setattr_called'
),
False
)
def
test_can_set__p_attrs_if_subclass_denies_setattr
(
self
):
from
persistent._compat
import
_b
# ZODB defines a PersistentBroken subclass that only lets us
# set things that start with _p, so make sure we can do that
class
Broken
(
self
.
_getTargetClass
()):
def
__setattr__
(
self
,
name
,
value
):
if
name
.
startswith
(
'_p_'
):
super
(
Broken
,
self
).
__setattr__
(
name
,
value
)
else
:
raise
TypeError
(
"Can't change broken objects"
)
KEY
=
_b
(
'123'
)
jar
=
self
.
_makeJar
()
broken
=
Broken
()
broken
.
_p_oid
=
KEY
broken
.
_p_jar
=
jar
broken
.
_p_changed
=
True
broken
.
_p_changed
=
0
class
PyPersistentTests
(
unittest
.
TestCase
,
_Persistent_Base
):
class
PyPersistentTests
(
unittest
.
TestCase
,
_Persistent_Base
):
def
_getTargetClass
(
self
):
def
_getTargetClass
(
self
):
...
...
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