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
a5f98fe6
Commit
a5f98fe6
authored
Feb 19, 2014
by
Tres Seaver
Browse files
Options
Browse Files
Download
Plain Diff
Resolve merge conflict.
parents
59310ca3
3975334c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
persistent/persistence.py
persistent/persistence.py
+10
-2
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+22
-0
No files found.
persistent/persistence.py
View file @
a5f98fe6
...
...
@@ -390,8 +390,16 @@ class Persistent(object):
# detail, the '_cache' attribute of the jar. We made it a
# private API to avoid the cycle of keeping a reference to
# the cache on the persistent object.
if
self
.
__jar
is
not
None
and
self
.
__oid
is
not
None
:
self
.
__jar
.
_cache
.
mru
(
self
.
__oid
)
if
self
.
__jar
is
not
None
and
self
.
__oid
is
not
None
and
self
.
_p_state
>=
0
:
# This scenario arises in ZODB: ZODB.serialize.ObjectWriter
# can assign a jar and an oid to newly seen persistent objects,
# but because they are newly created, they aren't in the
# pickle cache yet. There doesn't seem to be a way to distinguish
# that at this level, all we can do is catch it
try
:
self
.
__jar
.
_cache
.
mru
(
self
.
__oid
)
except
KeyError
:
pass
def
_estimated_size_in_24_bits
(
value
):
...
...
persistent/tests/test_persistence.py
View file @
a5f98fe6
...
...
@@ -1328,6 +1328,28 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
def
_clearMRU
(
self
,
jar
):
jar
.
_cache
.
_mru
[:]
=
[]
def
test_accessed_with_jar_and_oid_but_not_in_cache
(
self
):
# This scenario arises in ZODB: ZODB.serialize.ObjectWriter
# can assign a jar and an oid to newly seen persistent objects,
# but because they are newly created, they aren't in the
# pickle cache yet.
# Nothing should blow up when this happens
from
persistent._compat
import
_b
KEY
=
_b
(
'123'
)
jar
=
self
.
_makeJar
()
c1
=
self
.
_makeOne
()
c1
.
_p_oid
=
KEY
c1
.
_p_jar
=
jar
orig_mru
=
jar
.
_cache
.
mru
def
mru
(
oid
):
# Mimic what the real cache does
if
oid
not
in
jar
.
_cache
.
_mru
:
raise
KeyError
(
oid
)
orig_mru
(
oid
)
jar
.
_cache
.
mru
=
mru
c1
.
_p_accessed
()
self
.
_checkMRU
(
jar
,
[])
_add_to_suite
=
[
PyPersistentTests
]
if
not
os
.
environ
.
get
(
'PURE_PYTHON'
):
...
...
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