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
899366bd
Commit
899366bd
authored
Oct 29, 2008
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an option to leave the base storage open when a demo storage is
closed.
parent
7be85c1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
src/ZODB/DemoStorage.py
src/ZODB/DemoStorage.py
+5
-2
src/ZODB/DemoStorage.test
src/ZODB/DemoStorage.test
+32
-4
No files found.
src/ZODB/DemoStorage.py
View file @
899366bd
...
...
@@ -36,7 +36,9 @@ class DemoStorage(object):
ZODB
.
interfaces
.
IStorageIteration
,
)
def
__init__
(
self
,
name
=
None
,
base
=
None
,
changes
=
None
):
def
__init__
(
self
,
name
=
None
,
base
=
None
,
changes
=
None
,
keep_base_open
=
False
):
self
.
_keep_base_open
=
keep_base_open
if
base
is
None
:
base
=
ZODB
.
MappingStorage
.
MappingStorage
()
self
.
base
=
base
...
...
@@ -71,7 +73,8 @@ class DemoStorage(object):
self
.
changes
.
cleanup
()
def
close
(
self
):
self
.
base
.
close
()
if
not
self
.
_keep_base_open
:
self
.
base
.
close
()
self
.
changes
.
close
()
if
getattr
(
self
,
'_blob_dir'
,
''
):
ZODB
.
blob
.
remove_committed_dir
(
self
.
_blob_dir
)
...
...
src/ZODB/DemoStorage.test
View file @
899366bd
...
...
@@ -2,10 +2,8 @@
DemoStorage
demo
(
doctest
)
==========================
Note
that
most
people
will
configure
the
storage
through
ZConfig
.
If
you
are
one
of
those
people
,
you
may
want
to
stop
here
.
:
)
The
examples
below
show
you
how
to
use
the
storage from Python, but they
also exercise lots of details you might not be interested in.
DemoStorages
provide
a
way
to
provide
incremental
updates
to
an
existing
,
base
,
storage
without
updating
the
storage
.
To
see
how
this
works
,
we
'll start by creating a base storage and
puting an object (in addition to the root object) in it:
...
...
@@ -122,7 +120,37 @@ Undo methods are simply copied from the changes storage:
... ]
[True, True, True, True]
Normally, when we close a demo storage, the changes and base storages
are closed:
>>> db.close()
>>> base._file.closed
True
>>> changes._file.closed
True
A common use case is to stack multiple DemoStorages, returning to a
previous state by popping a DemoStorage off the stack. In this case,
we want to leave the base storage open:
>>> base = FileStorage('
base
.
fs
', read_only=True)
>>> storage = DemoStorage(base=base, keep_base_open=True)
Here, we didn'
t
specify
a
changes
storage
.
A
MappingStorage
was
automatically
created
:
>>>
type
(
storage
.
changes
)
.
__name__
'MappingStorage'
Because
we
specified
the
keep_base_open
option
,
the
base
storage
is
left
open
when
we
close
the
DemoStorage
:
>>>
storage
.
close
()
>>>
base
.
_file
.
closed
False
>>>
storage
.
changes
.
opened
()
False
Blob
Support
============
...
...
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