Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
249d78d3
Commit
249d78d3
authored
Feb 19, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
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
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