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
nexedi
ZODB
Commits
0a2670a2
Commit
0a2670a2
authored
Jul 04, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forgot to add a file again...
parent
eec49810
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
src/ZODB/multicommitadapter.py
src/ZODB/multicommitadapter.py
+65
-0
No files found.
src/ZODB/multicommitadapter.py
0 → 100644
View file @
0a2670a2
"""Adapt non-IMultiCommitStorage storages to IMultiCommitStorage
"""
import
zope.interface
from
.ConflictResolution
import
ResolvedSerial
class
MultiCommitAdapter
:
def
__init__
(
self
,
storage
):
self
.
_storage
=
storage
ifaces
=
zope
.
interface
.
providedBy
(
storage
)
zope
.
interface
.
alsoProvides
(
self
,
ifaces
)
self
.
_resolved
=
set
()
def
__getattr__
(
self
,
name
):
v
=
getattr
(
self
.
_storage
,
name
)
self
.
__dict__
[
name
]
=
v
return
v
def
tpc_begin
(
self
,
*
args
):
self
.
_storage
.
tpc_begin
(
*
args
)
self
.
_resolved
=
set
()
def
store
(
self
,
oid
,
*
args
):
if
self
.
_storage
.
store
(
oid
,
*
args
)
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
def
storeBlob
(
self
,
oid
,
*
args
):
s
=
self
.
_storage
.
storeBlob
(
oid
,
*
args
)
if
s
:
if
isinstance
(
s
,
bytes
):
s
=
((
oid
,
s
),
)
for
oid
,
serial
in
s
:
if
s
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
def
undo
(
self
,
transaction_id
,
transaction
):
r
=
self
.
_storage
.
undo
(
transaction_id
,
transaction
)
if
r
:
self
.
_resolved
.
update
(
set
(
r
[
1
]))
def
tpc_vote
(
self
,
*
args
):
s
=
self
.
_storage
.
tpc_vote
(
*
args
)
for
(
oid
,
serial
)
in
(
s
or
()):
if
serial
==
ResolvedSerial
:
self
.
_resolved
.
add
(
oid
)
return
list
(
self
.
_resolved
)
def
tpc_finish
(
self
,
transaction
,
f
=
lambda
tid
:
None
):
t
=
[]
def
func
(
tid
):
t
.
append
(
tid
)
f
(
tid
)
self
.
_storage
.
tpc_finish
(
transaction
,
func
)
return
t
[
0
]
def
__len__
(
self
):
return
len
(
self
.
_storage
)
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