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
e0979e3c
Commit
e0979e3c
authored
Apr 10, 2001
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made tryToResolveConflict available as stand-alone function.
parent
c5198c46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
51 deletions
+52
-51
trunk/src/ZODB/ConflictResolution.py
trunk/src/ZODB/ConflictResolution.py
+52
-51
No files found.
trunk/src/ZODB/ConflictResolution.py
View file @
e0979e3c
...
@@ -142,60 +142,61 @@ def persistent_id(object,
...
@@ -142,60 +142,61 @@ def persistent_id(object,
return
None
return
None
return
object
.
data
return
object
.
data
class
ConflictResolvingStorage
:
def
tryToResolveConflict
(
self
,
oid
,
committedSerial
,
oldSerial
,
newpickle
):
"Mix-in class that provides conflict resolution handling for storages"
#class_tuple, old, committed, newstate = ('',''), 0, 0, 0
try
:
file
=
StringIO
(
newpickle
)
unpickler
=
Unpickler
(
file
)
prfactory
=
PersistentReferenceFactory
()
unpickler
.
persistent_load
=
prfactory
class_tuple
=
unpickler
.
load
()[
0
]
if
bad_class
(
class_tuple
):
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
newstate
=
unpickler
.
load
()
klass
=
_classFactory
(
class_tuple
[
0
],
class_tuple
[
1
])
klass
.
_p_resolveConflict
inst
=
klass
.
__basicnew__
()
def
tryToResolveConflict
(
self
,
oid
,
committedSerial
,
oldSerial
,
newpickle
):
#class_tuple, old, committed, newstate = ('',''), 0, 0, 0
try
:
try
:
file
=
StringIO
(
newpickle
)
resolve
=
inst
.
_p_resolveConflict
unpickler
=
Unpickler
(
file
)
except
AttributeError
:
prfactory
=
PersistentReferenceFactory
()
bad_classes
[
class_tuple
]
=
1
unpickler
.
persistent_load
=
prfactory
class_tuple
=
unpickler
.
load
()[
0
]
if
bad_class
(
class_tuple
):
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
newstate
=
unpickler
.
load
()
klass
=
_classFactory
(
class_tuple
[
0
],
class_tuple
[
1
])
klass
.
_p_resolveConflict
inst
=
klass
.
__basicnew__
()
try
:
resolve
=
inst
.
_p_resolveConflict
except
AttributeError
:
bad_classes
[
class_tuple
]
=
1
#traceback.print_exc()
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
old
=
state
(
self
,
oid
,
oldSerial
,
prfactory
)
committed
=
state
(
self
,
oid
,
committedSerial
,
prfactory
)
resolved
=
resolve
(
old
,
committed
,
newstate
)
file
=
StringIO
()
pickler
=
Pickler
(
file
,
1
)
pickler
.
persistent_id
=
persistent_id
pickler
.
dump
(
class_tuple
)
pickler
.
dump
(
resolved
)
#sys.stderr.write(' r%s ' % class_tuple[1]); sys.stderr.flush()
return
file
.
getvalue
(
1
)
except
Exception
,
v
:
#print '='*70
#print v, v.args
#print '='*70
#print old
#print '='*70
#print committed
#print '='*70
#print newstate
#print '='*70
#traceback.print_exc()
#traceback.print_exc()
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
#sys.stderr.write(' c%s ' % class_tuple[1]); sys.stderr.flush()
old
=
state
(
self
,
oid
,
oldSerial
,
prfactory
)
committed
=
state
(
self
,
oid
,
committedSerial
,
prfactory
)
return
0
resolved
=
resolve
(
old
,
committed
,
newstate
)
file
=
StringIO
()
pickler
=
Pickler
(
file
,
1
)
pickler
.
persistent_id
=
persistent_id
pickler
.
dump
(
class_tuple
)
pickler
.
dump
(
resolved
)
#sys.stderr.write(' r%s ' % class_tuple[1]); sys.stderr.flush()
return
file
.
getvalue
(
1
)
except
Exception
,
v
:
#print '='*70
#print v, v.args
#print '='*70
#print old
#print '='*70
#print committed
#print '='*70
#print newstate
#print '='*70
#traceback.print_exc()
#sys.stderr.write(' c%s ' % class_tuple[1]); sys.stderr.flush()
return
0
class
ConflictResolvingStorage
:
"Mix-in class that provides conflict resolution handling for storages"
tryToResolveConflict
=
tryToResolveConflict
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