Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Kirill Smelkov
ZEO
Commits
1f66b3c1
Commit
1f66b3c1
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
618a6b8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
51 deletions
+52
-51
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+52
-51
No files found.
src/ZODB/ConflictResolution.py
View file @
1f66b3c1
...
...
@@ -142,60 +142,61 @@ def persistent_id(object,
return
None
return
object
.
data
class
ConflictResolvingStorage
:
"Mix-in class that provides conflict resolution handling for storages"
def
tryToResolveConflict
(
self
,
oid
,
committedSerial
,
oldSerial
,
newpickle
):
#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
:
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__
()
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
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
#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