Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
ZODB
Commits
249d78d3
Commit
249d78d3
authored
21 years ago
by
Jeremy Hylton
Browse files
Options
Download
Email Patches
Plain Diff
One more try. Commit the version with referencesf.
parent
f0fb3552
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
trunk/src/ZODB/serialize.py
trunk/src/ZODB/serialize.py
+52
-0
No files found.
trunk/src/ZODB/serialize.py
View file @
249d78d3
...
...
@@ -427,3 +427,55 @@ class ConnectionObjectReader(BaseObjectReader):
if
obj
is
not
None
:
return
obj
return
self
.
_conn
[
oid
]
def
referencesf
(
p
,
rootl
=
None
):
if
rootl
is
None
:
rootl
=
[]
u
=
cPickle
.
Unpickler
(
cStringIO
.
StringIO
(
p
))
l
=
len
(
rootl
)
u
.
persistent_load
=
rootl
u
.
noload
()
try
:
u
.
noload
()
except
:
# Hm. We failed to do second load. Maybe there wasn't a
# second pickle. Let's check:
f
=
cStringIO
.
StringIO
(
p
)
u
=
cPickle
.
Unpickler
(
f
)
u
.
persistent_load
=
[]
u
.
noload
()
if
len
(
p
)
>
f
.
tell
():
raise
ValueError
,
'Error unpickling, %s'
%
p
# References may be:
#
# - A tuple, in which case they are an oid and class.
# In this case, just extract the first element, which is
# the oid
#
# - A list, which is a weak reference. We skip those.
#
# - Anything else must be an oid. This means that an oid
# may not be a list or a tuple. This is a bit lame.
# We could avoid this lamosity by allowing single-element
# tuples, so that we wrap oids that are lists or tuples in
# tuples.
#
# - oids may *not* be false. I'm not sure why.
out
=
[]
for
v
in
rootl
:
assert
v
# Let's see if we ever get empty ones
if
type
(
v
)
is
list
:
# skip wekrefs
continue
if
type
(
v
)
is
tuple
:
v
=
v
[
0
]
out
.
append
(
v
)
rootl
[:]
=
out
return
rootl
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