Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
583b2853
Commit
583b2853
authored
Mar 12, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
027f9a6b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
lib/tests/test_zodb.py
lib/tests/test_zodb.py
+42
-1
lib/zodb.py
lib/zodb.py
+3
-1
No files found.
lib/tests/test_zodb.py
View file @
583b2853
...
...
@@ -17,13 +17,15 @@
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from
wendelin.lib.zodb
import
LivePersistent
,
deactivate_btree
,
dbclose
from
wendelin.lib.zodb
import
LivePersistent
,
deactivate_btree
,
dbclose
,
zconn_at
from
wendelin.lib.testing
import
getTestDB
from
persistent
import
Persistent
,
UPTODATE
,
GHOST
,
CHANGED
from
ZODB
import
DB
,
POSException
from
BTrees.IOBTree
import
IOBTree
import
transaction
from
transaction
import
TransactionManager
from
golang
import
defer
,
func
from
pytest
import
raises
import
gc
testdb
=
None
...
...
@@ -228,7 +230,46 @@ def test_deactivate_btree():
assert
obj
not
in
cached
# zsync syncs ZODB storage.
# it is noop, if zstor does not support syncing (i.e. FileStorage has no .sync())
def
zsync
(
zstor
):
sync
=
getattr
(
zstor
,
'sync'
,
None
)
if
sync
is
not
None
:
sync
()
@
func
def
test_zconn_at
():
stor
=
testdb
.
getZODBStorage
()
defer
(
stor
.
close
)
db
=
DB
(
stor
)
zsync
(
stor
)
at0
=
stor
.
lastTransaction
()
# open connection, it must be viewing the database @at0
conn1
=
db
.
open
()
assert
zconn_at
(
conn1
)
==
at0
# commit
root1
=
conn1
.
root
()
root1
[
'z'
]
=
1
transaction
.
commit
()
# after commit the view is updated
zsync
(
stor
)
at1
=
stor
.
lastTransaction
()
assert
zconn_at
(
conn1
)
==
at1
# still at at0 XXX ok?
# reopen -> view @at1
conn1
.
close
()
with
raises
(
POSException
.
ConnectionStateError
):
zconn_at
(
conn1
)
conn2
=
db
.
open
()
assert
conn2
is
conn1
# returned from DB pool
assert
zconn_at
(
conn2
)
==
at1
conn2
.
close
()
# TODO commit -> know head -> open conn1,
# open conn2, commit there; wait or sync, make sure zconn_at(conn1) is as expected
...
...
lib/zodb.py
View file @
583b2853
...
...
@@ -22,6 +22,7 @@
import
ZODB
from
ZODB.FileStorage
import
FileStorage
from
ZODB
import
DB
from
ZODB
import
POSException
from
ZODB.utils
import
p64
,
u64
from
persistent
import
Persistent
from
weakref
import
WeakSet
...
...
@@ -141,7 +142,8 @@ def _deactivate_bucket(bucket):
# zconn_at returns tid as of which ZODB connection is viewing the database.
def
zconn_at
(
zconn
):
# -> tid
assert
isinstance
(
zconn
,
ZODB
.
Connection
.
Connection
)
# XXX assert zconn is opened
if
zconn
.
opened
is
None
:
# zconn must be in "opened" state
raise
POSException
.
ConnectionStateError
(
"database connection is closed"
)
# ZODB5 uses MVCC uniformly
if
zmajor
>=
5
:
...
...
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