Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
dd9f5833
Commit
dd9f5833
authored
Feb 19, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ack! Deleted the wrong file in the last checkin.
parent
f338d794
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
429 additions
and
68 deletions
+429
-68
src/ZODB/referencesf.py
src/ZODB/referencesf.py
+0
-68
src/ZODB/serialize.py
src/ZODB/serialize.py
+429
-0
No files found.
src/ZODB/referencesf.py
deleted
100644 → 0
View file @
f338d794
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""Provide a function that can find object references in pickles
"""
import
cPickle
,
cStringIO
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
src/ZODB/serialize.py
0 → 100644
View file @
dd9f5833
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