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
nexedi
ZODB
Commits
4618b7b1
Commit
4618b7b1
authored
Sep 18, 2008
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move fake jar out to utils; add another version which remembers state.
parent
2ad69fde
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
src/persistent/tests/utils.py
src/persistent/tests/utils.py
+79
-0
No files found.
src/persistent/tests/utils.py
0 → 100644
View file @
4618b7b1
class
ResettingJar
(
object
):
"""Testing stub for _p_jar attribute.
"""
def
__init__
(
self
):
from
persistent.cPickleCache
import
PickleCache
# XXX stub it!
self
.
cache
=
PickleCache
(
self
)
self
.
oid
=
1
self
.
registered
=
{}
def
add
(
self
,
obj
):
import
struct
obj
.
_p_oid
=
struct
.
pack
(
">Q"
,
self
.
oid
)
self
.
oid
+=
1
obj
.
_p_jar
=
self
self
.
cache
[
obj
.
_p_oid
]
=
obj
def
close
(
self
):
pass
# the following methods must be implemented to be a jar
def
setklassstate
(
self
):
# I don't know what this method does, but the pickle cache
# constructor calls it.
pass
def
register
(
self
,
obj
):
self
.
registered
[
obj
]
=
1
def
setstate
(
self
,
obj
):
# Trivial setstate() implementation that just re-initializes
# the object. This isn't what setstate() is supposed to do,
# but it suffices for the tests.
obj
.
__class__
.
__init__
(
obj
)
class
RememberingJar
(
object
):
"""Testing stub for _p_jar attribute.
"""
def
__init__
(
self
):
from
persistent.cPickleCache
import
PickleCache
# XXX stub it!
self
.
cache
=
PickleCache
(
self
)
self
.
oid
=
1
self
.
registered
=
{}
def
add
(
self
,
obj
):
import
struct
obj
.
_p_oid
=
struct
.
pack
(
">Q"
,
self
.
oid
)
self
.
oid
+=
1
obj
.
_p_jar
=
self
self
.
cache
[
obj
.
_p_oid
]
=
obj
# Remember object's state for later.
self
.
obj
=
obj
self
.
remembered
=
obj
.
__getstate__
()
def
close
(
self
):
pass
def
fake_commit
(
self
):
self
.
remembered
=
self
.
obj
.
__getstate__
()
self
.
obj
.
_p_changed
=
0
# the following methods must be implemented to be a jar
def
setklassstate
(
self
):
# I don't know what this method does, but the pickle cache
# constructor calls it.
pass
def
register
(
self
,
obj
):
self
.
registered
[
obj
]
=
1
def
setstate
(
self
,
obj
):
# Trivial setstate() implementation that resets the object's
# state as of the time it was added to the jar.
# This isn't what setstate() is supposed to do,
# but it suffices for the tests.
obj
.
__setstate__
(
self
.
remembered
)
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