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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
ZODB
Commits
9d13627c
Commit
9d13627c
authored
May 04, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DemoStorage: add support for conflict resolution
parent
ee5a462b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+6
-1
src/ZODB/DemoStorage.py
src/ZODB/DemoStorage.py
+6
-4
src/ZODB/tests/testDemoStorage.py
src/ZODB/tests/testDemoStorage.py
+7
-6
No files found.
src/ZODB/ConflictResolution.py
View file @
9d13627c
...
...
@@ -313,4 +313,9 @@ class ConflictResolvingStorage(object):
def
registerDB
(
self
,
wrapper
):
self
.
_crs_untransform_record_data
=
wrapper
.
untransform_record_data
self
.
_crs_transform_record_data
=
wrapper
.
transform_record_data
super
(
ConflictResolvingStorage
,
self
).
registerDB
(
wrapper
)
try
:
m
=
super
(
ConflictResolvingStorage
,
self
).
registerDB
except
AttributeError
:
pass
else
:
m
(
wrapper
)
src/ZODB/DemoStorage.py
View file @
9d13627c
...
...
@@ -31,12 +31,13 @@ import ZODB.MappingStorage
import
ZODB.POSException
import
ZODB.utils
import
zope.interface
from
.ConflictResolution
import
ConflictResolvingStorage
,
ResolvedSerial
@
zope
.
interface
.
implementer
(
ZODB
.
interfaces
.
IStorage
,
ZODB
.
interfaces
.
IStorageIteration
,
)
class
DemoStorage
(
object
):
class
DemoStorage
(
ConflictResolvingStorage
):
def
__init__
(
self
,
name
=
None
,
base
=
None
,
changes
=
None
,
...
...
@@ -112,7 +113,7 @@ class DemoStorage(object):
def
_copy_methods_from_changes
(
self
,
changes
):
for
meth
in
(
'_lock_acquire'
,
'_lock_release'
,
'getSize'
,
'history'
,
'isReadOnly'
,
'registerDB'
,
'getSize'
,
'history'
,
'isReadOnly'
,
'sortKey'
,
'tpc_transaction'
,
'tpc_vote'
,
):
setattr
(
self
,
meth
,
getattr
(
changes
,
meth
))
...
...
@@ -281,8 +282,9 @@ class DemoStorage(object):
old
=
serial
if
old
!=
serial
:
raise
ZODB
.
POSException
.
ConflictError
(
oid
=
oid
,
serials
=
(
old
,
serial
))
# XXX untested branch
rdata
=
self
.
tryToResolveConflict
(
oid
,
old
,
serial
,
data
)
self
.
changes
.
store
(
oid
,
old
,
rdata
,
''
,
transaction
)
return
ResolvedSerial
return
self
.
changes
.
store
(
oid
,
serial
,
data
,
''
,
transaction
)
...
...
src/ZODB/tests/testDemoStorage.py
View file @
9d13627c
...
...
@@ -14,6 +14,7 @@
from
ZODB.DB
import
DB
from
ZODB.tests
import
(
BasicStorage
,
ConflictResolution
,
HistoryStorage
,
IteratorStorage
,
MTStorage
,
...
...
@@ -42,7 +43,7 @@ from zope.testing import renormalizing
class
DemoStorageTests
(
StorageTestBase
.
StorageTestBase
,
BasicStorage
.
BasicStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
HistoryStorage
.
HistoryStorage
,
IteratorStorage
.
ExtendedIteratorStorage
,
IteratorStorage
.
IteratorStorage
,
...
...
@@ -144,11 +145,11 @@ def testSomeDelegation():
>>> class S:
... def __init__(self, name):
... self.name = name
... def
registerDB(self, db
):
... six.print_(self.name,
db
)
... def
getSize(self
):
... six.print_(self.name,
'size'
)
... def close(self):
... six.print_(self.name, 'closed')
... sortKey =
getSize =
__len__ = history = getTid = None
... sortKey = __len__ = history = getTid = None
... tpc_finish = tpc_vote = tpc_transaction = None
... _lock_acquire = _lock_release = lambda self: None
... getName = lambda self: 'S'
...
...
@@ -165,8 +166,8 @@ def testSomeDelegation():
>>> from ZODB.DemoStorage import DemoStorage
>>> storage = DemoStorage(base=S(1), changes=S(2))
>>> storage.
registerDB(1
)
2
1
>>> storage.
getSize(
)
2
size
>>> storage.close()
1 closed
...
...
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