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
Joshua
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
Show 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):
...
@@ -313,4 +313,9 @@ class ConflictResolvingStorage(object):
def
registerDB
(
self
,
wrapper
):
def
registerDB
(
self
,
wrapper
):
self
.
_crs_untransform_record_data
=
wrapper
.
untransform_record_data
self
.
_crs_untransform_record_data
=
wrapper
.
untransform_record_data
self
.
_crs_transform_record_data
=
wrapper
.
transform_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
...
@@ -31,12 +31,13 @@ import ZODB.MappingStorage
import
ZODB.POSException
import
ZODB.POSException
import
ZODB.utils
import
ZODB.utils
import
zope.interface
import
zope.interface
from
.ConflictResolution
import
ConflictResolvingStorage
,
ResolvedSerial
@
zope
.
interface
.
implementer
(
@
zope
.
interface
.
implementer
(
ZODB
.
interfaces
.
IStorage
,
ZODB
.
interfaces
.
IStorage
,
ZODB
.
interfaces
.
IStorageIteration
,
ZODB
.
interfaces
.
IStorageIteration
,
)
)
class
DemoStorage
(
object
):
class
DemoStorage
(
ConflictResolvingStorage
):
def
__init__
(
self
,
name
=
None
,
base
=
None
,
changes
=
None
,
def
__init__
(
self
,
name
=
None
,
base
=
None
,
changes
=
None
,
...
@@ -112,7 +113,7 @@ class DemoStorage(object):
...
@@ -112,7 +113,7 @@ class DemoStorage(object):
def
_copy_methods_from_changes
(
self
,
changes
):
def
_copy_methods_from_changes
(
self
,
changes
):
for
meth
in
(
for
meth
in
(
'_lock_acquire'
,
'_lock_release'
,
'_lock_acquire'
,
'_lock_release'
,
'getSize'
,
'history'
,
'isReadOnly'
,
'registerDB'
,
'getSize'
,
'history'
,
'isReadOnly'
,
'sortKey'
,
'tpc_transaction'
,
'tpc_vote'
,
'sortKey'
,
'tpc_transaction'
,
'tpc_vote'
,
):
):
setattr
(
self
,
meth
,
getattr
(
changes
,
meth
))
setattr
(
self
,
meth
,
getattr
(
changes
,
meth
))
...
@@ -281,8 +282,9 @@ class DemoStorage(object):
...
@@ -281,8 +282,9 @@ class DemoStorage(object):
old
=
serial
old
=
serial
if
old
!=
serial
:
if
old
!=
serial
:
raise
ZODB
.
POSException
.
ConflictError
(
rdata
=
self
.
tryToResolveConflict
(
oid
,
old
,
serial
,
data
)
oid
=
oid
,
serials
=
(
old
,
serial
))
# XXX untested branch
self
.
changes
.
store
(
oid
,
old
,
rdata
,
''
,
transaction
)
return
ResolvedSerial
return
self
.
changes
.
store
(
oid
,
serial
,
data
,
''
,
transaction
)
return
self
.
changes
.
store
(
oid
,
serial
,
data
,
''
,
transaction
)
...
...
src/ZODB/tests/testDemoStorage.py
View file @
9d13627c
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
ZODB.DB
import
DB
from
ZODB.DB
import
DB
from
ZODB.tests
import
(
from
ZODB.tests
import
(
BasicStorage
,
BasicStorage
,
ConflictResolution
,
HistoryStorage
,
HistoryStorage
,
IteratorStorage
,
IteratorStorage
,
MTStorage
,
MTStorage
,
...
@@ -42,7 +43,7 @@ from zope.testing import renormalizing
...
@@ -42,7 +43,7 @@ from zope.testing import renormalizing
class
DemoStorageTests
(
class
DemoStorageTests
(
StorageTestBase
.
StorageTestBase
,
StorageTestBase
.
StorageTestBase
,
BasicStorage
.
BasicStorage
,
BasicStorage
.
BasicStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
HistoryStorage
.
HistoryStorage
,
HistoryStorage
.
HistoryStorage
,
IteratorStorage
.
ExtendedIteratorStorage
,
IteratorStorage
.
ExtendedIteratorStorage
,
IteratorStorage
.
IteratorStorage
,
IteratorStorage
.
IteratorStorage
,
...
@@ -144,11 +145,11 @@ def testSomeDelegation():
...
@@ -144,11 +145,11 @@ def testSomeDelegation():
>>> class S:
>>> class S:
... def __init__(self, name):
... def __init__(self, name):
... self.name = name
... self.name = name
... def
registerDB(self, db
):
... def
getSize(self
):
... six.print_(self.name,
db
)
... six.print_(self.name,
'size'
)
... def close(self):
... def close(self):
... six.print_(self.name, 'closed')
... six.print_(self.name, 'closed')
... sortKey =
getSize =
__len__ = history = getTid = None
... sortKey = __len__ = history = getTid = None
... tpc_finish = tpc_vote = tpc_transaction = None
... tpc_finish = tpc_vote = tpc_transaction = None
... _lock_acquire = _lock_release = lambda self: None
... _lock_acquire = _lock_release = lambda self: None
... getName = lambda self: 'S'
... getName = lambda self: 'S'
...
@@ -165,8 +166,8 @@ def testSomeDelegation():
...
@@ -165,8 +166,8 @@ def testSomeDelegation():
>>> from ZODB.DemoStorage import DemoStorage
>>> from ZODB.DemoStorage import DemoStorage
>>> storage = DemoStorage(base=S(1), changes=S(2))
>>> storage = DemoStorage(base=S(1), changes=S(2))
>>> storage.
registerDB(1
)
>>> storage.
getSize(
)
2
1
2
size
>>> storage.close()
>>> storage.close()
1 closed
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