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
caea03ca
Commit
caea03ca
authored
Jun 19, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IStorage: simplify the API of store/tpc_finish to notify of resolved conflicts
parent
cf02e50a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
+24
-15
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+1
-1
src/ZODB/Connection.py
src/ZODB/Connection.py
+13
-5
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+8
-7
src/ZODB/tests/testDemoStorage.py
src/ZODB/tests/testDemoStorage.py
+2
-2
No files found.
src/ZODB/ConflictResolution.py
View file @
caea03ca
...
...
@@ -28,7 +28,7 @@ from pickle import PicklingError
logger
=
logging
.
getLogger
(
'ZODB.ConflictResolution'
)
ResolvedSerial
=
b'rs'
ResolvedSerial
=
b'rs'
# deprecated: store/tpc_finish should just use True
class
BadClassName
(
Exception
):
pass
...
...
src/ZODB/Connection.py
View file @
caea03ca
...
...
@@ -705,7 +705,7 @@ class Connection(ExportImport, object):
self
.
_handle_serial
(
oid
,
s
)
def
_handle_serial
(
self
,
oid
,
serial
,
change
=
True
):
def
_handle_serial
(
self
,
oid
,
serial
=
True
,
change
=
True
):
# if we write an object, we don't want to check if it was read
# while current. This is a convenient choke point to do this.
...
...
@@ -713,7 +713,9 @@ class Connection(ExportImport, object):
if
not
serial
:
return
if
not
isinstance
(
serial
,
bytes
):
if
serial
is
True
:
serial
=
ResolvedSerial
elif
not
isinstance
(
serial
,
bytes
):
raise
serial
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
None
:
...
...
@@ -721,6 +723,7 @@ class Connection(ExportImport, object):
if
serial
==
ResolvedSerial
:
del
obj
.
_p_changed
# transition from changed to ghost
else
:
self
.
_warn_about_returned_serial
()
if
change
:
obj
.
_p_changed
=
0
# transition from changed to up-to-date
obj
.
_p_serial
=
serial
...
...
@@ -790,6 +793,11 @@ class Connection(ExportImport, object):
raise
if
s
:
if
type
(
s
[
0
])
is
bytes
:
for
oid
in
s
:
self
.
_handle_serial
(
oid
)
return
self
.
_warn_about_returned_serial
()
for
oid
,
serial
in
s
:
self
.
_handle_serial
(
oid
,
serial
)
...
...
@@ -829,9 +837,9 @@ class Connection(ExportImport, object):
self
.
_warn_about_returned_serial
=
lambda
:
None
else
:
warnings
.
warn
(
"In ZODB 5+,
it will be required for tpc_finish to return the
"
"
committed tid. store/tpc_vote will only have to notify about
"
"
resolved conflicts
."
,
"In ZODB 5+,
the new API for the returned value of
"
"
store/tpc_vote/tpc_finish will be mandatory.
"
"
See IStorage for more information
."
,
DeprecationWarning
,
2
)
Connection
.
_warn_about_returned_serial
=
lambda
self
:
None
...
...
src/ZODB/interfaces.py
View file @
caea03ca
...
...
@@ -797,13 +797,14 @@ class IStorage(Interface):
without an error, then there must not be an error if
tpc_finish or tpc_abort is called subsequently.
The return value can be either None or a sequence of object-id
and serial pairs giving new serials for objects who's ids were
passed to previous store calls in the same transaction.
A serial returned in a sequence of oid/serial pairs, may be
the special value ZODB.ConflictResolution.ResolvedSerial to
indicate that a conflict occured and that the object should be
The return value can be either None or a sequence of oids for which
a conflict was resolved.
For compatibility, the return value can also be a sequence of object-id
and serial pairs giving new serials for objects whose ids were
passed to previous store calls in the same transaction. The serial
can be the special value ZODB.ConflictResolution.ResolvedSerial to
indicate that a conflict occurred and that the object should be
invalidated.
After the tpc_vote call, all solved conflicts must have been notified,
...
...
src/ZODB/tests/testDemoStorage.py
View file @
caea03ca
...
...
@@ -58,8 +58,8 @@ class DemoStorage(ZODB.DemoStorage.DemoStorage):
assert
type
(
s
)
is
bytes
,
s
return
if
not
self
.
delayed_store
:
return
s
self
.
__stored
.
append
(
(
oid
,
s
)
)
return
True
self
.
__stored
.
append
(
oid
)
tpc_vote
=
property
(
lambda
self
:
self
.
_tpc_vote
,
lambda
*
_
:
None
)
...
...
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