Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Aurélien Vermylen
erp5
Commits
77f9030e
Commit
77f9030e
authored
Jan 03, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DemoStorage: update conflict resolution patch for ZODB 3.10
parent
4718f5e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
32 deletions
+15
-32
product/ERP5Type/patches/DemoStorage.py
product/ERP5Type/patches/DemoStorage.py
+15
-32
No files found.
product/ERP5Type/patches/DemoStorage.py
View file @
77f9030e
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
# Copyright (c) 2010-2013 Nexedi SARL and Contributors. All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
@@ -13,43 +12,27 @@
...
@@ -13,43 +12,27 @@
#
#
##############################################################################
##############################################################################
from
ZODB.DemoStorage
import
DemoStorage
from
ZODB
import
DemoStorage
as
_DemoStorage
from
ZODB.ConflictResolution
import
tryToResolveConflict
,
ResolvedSerial
from
ZODB.ConflictResolution
import
ConflictResolvingStorage
,
ResolvedSerial
from
ZODB.POSException
import
ConflictError
if
1
:
assert
not
issubclass
(
_DemoStorage
.
DemoStorage
,
ConflictResolvingStorage
)
class
DemoStorage
(
_DemoStorage
.
DemoStorage
,
ConflictResolvingStorage
):
##
##
# Implement conflict resolution for DemoStorage
# Implement conflict resolution for DemoStorage
#
#
import
ZODB.POSException
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
assert
version
==
''
,
"versions aren't supported"
if
transaction
is
not
self
.
_transaction
:
raise
ZODB
.
POSException
.
StorageTransactionError
(
self
,
transaction
)
# Since the OID is being used, we don't have to keep up with it any
# more. Save it now so we can forget it later. :)
self
.
_stored_oids
.
add
(
oid
)
# See if we already have changes for this oid
try
:
try
:
old
=
self
.
changes
.
load
(
oid
,
''
)[
1
]
return
super
(
DemoStorage
,
self
).
store
(
except
ZODB
.
POSException
.
POSKeyError
:
oid
,
serial
,
data
,
version
,
transaction
)
try
:
except
ConflictError
,
e
:
old
=
self
.
base
.
load
(
oid
,
''
)[
1
]
old
=
e
.
serials
[
0
]
except
ZODB
.
POSException
.
POSKeyError
:
rdata
=
self
.
tryToResolveConflict
(
oid
,
old
,
serial
,
data
)
old
=
serial
if
rdata
is
None
:
# BBB: Zope < 2.13
raise
ConflictError
(
oid
=
oid
,
serials
=
(
old
,
serial
),
data
=
data
)
if
old
!=
serial
:
# <patch>
rdata
=
tryToResolveConflict
(
self
,
oid
,
old
,
serial
,
data
)
if
rdata
is
None
:
raise
ZODB
.
POSException
.
ConflictError
(
oid
=
oid
,
serials
=
(
old
,
serial
),
data
=
data
)
self
.
changes
.
store
(
oid
,
old
,
rdata
,
''
,
transaction
)
self
.
changes
.
store
(
oid
,
old
,
rdata
,
''
,
transaction
)
return
ResolvedSerial
return
ResolvedSerial
# </patch>
return
self
.
changes
.
store
(
oid
,
serial
,
data
,
''
,
transaction
)
DemoStorage
.
store
=
stor
e
_DemoStorage
.
DemoStorage
=
DemoStorag
e
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