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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
2aaec188
Commit
2aaec188
authored
Aug 14, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
General code cleanup -- whitespace, local variable alias removal, &c.
parent
40dfaecb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
43 deletions
+35
-43
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+35
-43
No files found.
src/ZODB/ConflictResolution.py
View file @
2aaec188
...
@@ -19,14 +19,15 @@ from ZODB.POSException import ConflictError
...
@@ -19,14 +19,15 @@ from ZODB.POSException import ConflictError
#import traceback
#import traceback
bad_classes
=
{}
bad_classes
=
{}
def
bad_class
(
class_tuple
):
def
bad_class
(
class_tuple
):
if
bad_classes
.
has_key
(
class_tuple
)
or
class_tuple
[
0
][
0
]
==
'*'
:
if
bad_classes
.
has_key
(
class_tuple
)
or
class_tuple
[
0
][
0
]
==
'*'
:
# if we've seen the class before or if it's a ZClass, we know that
# if we've seen the class before or if it's a ZClass, we know that
# we can't resolve the conflict
# we can't resolve the conflict
return
1
return
1
ResolvedSerial
=
'rs'
ResolvedSerial
=
'rs'
def
_classFactory
(
location
,
name
,
def
_classFactory
(
location
,
name
,
_silly
=
(
'__doc__'
,),
_globals
=
{}):
_silly
=
(
'__doc__'
,),
_globals
=
{}):
...
@@ -34,12 +35,12 @@ def _classFactory(location, name,
...
@@ -34,12 +35,12 @@ def _classFactory(location, name,
name
)
name
)
def
state
(
self
,
oid
,
serial
,
prfactory
,
p
=
''
):
def
state
(
self
,
oid
,
serial
,
prfactory
,
p
=
''
):
p
=
p
or
self
.
loadSerial
(
oid
,
serial
)
p
=
p
or
self
.
loadSerial
(
oid
,
serial
)
file
=
StringIO
(
p
)
file
=
StringIO
(
p
)
unpickler
=
Unpickler
(
file
)
unpickler
=
Unpickler
(
file
)
unpickler
.
persistent_load
=
prfactory
unpickler
.
persistent_load
=
prfactory
.
persistent_load
class_tuple
=
unpickler
.
load
()
class_tuple
=
unpickler
.
load
()
state
=
unpickler
.
load
()
state
=
unpickler
.
load
()
return
state
return
state
...
@@ -53,26 +54,21 @@ class PersistentReference:
...
@@ -53,26 +54,21 @@ class PersistentReference:
class
PersistentReferenceFactory
:
class
PersistentReferenceFactory
:
data
=
None
data
=
None
def
__call__
(
self
,
oid
,
getattr
=
getattr
,
None
=
None
):
data
=
self
.
data
def
persistent_load
(
self
,
oid
):
if
not
data
:
data
=
self
.
data
=
{}
if
self
.
data
is
None
:
self
.
data
=
{}
r
=
data
.
get
(
oid
,
None
)
r
=
self
.
data
.
get
(
oid
,
None
)
if
r
is
None
:
if
r
is
None
:
r
=
PersistentReference
()
r
=
PersistentReference
()
r
.
data
=
oid
r
.
data
=
oid
data
[
oid
]
=
r
self
.
data
[
oid
]
=
r
return
r
return
r
def
persistent_id
(
object
,
def
persistent_id
(
object
):
PersistentReference
=
PersistentReference
,
getattr
=
getattr
):
if
getattr
(
object
,
'__class__'
,
0
)
is
not
PersistentReference
:
if
getattr
(
object
,
'__class__'
,
0
)
is
not
PersistentReference
:
return
None
return
None
return
object
.
data
return
object
.
data
...
@@ -81,38 +77,34 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
...
@@ -81,38 +77,34 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
committedData
=
''
):
committedData
=
''
):
#class_tuple, old, committed, newstate = ('',''), 0, 0, 0
#class_tuple, old, committed, newstate = ('',''), 0, 0, 0
try
:
try
:
file
=
StringIO
(
newpickle
)
file
=
StringIO
(
newpickle
)
unpickler
=
Unpickler
(
file
)
unpickler
=
Unpickler
(
file
)
prfactory
=
PersistentReferenceFactory
()
prfactory
=
PersistentReferenceFactory
()
unpickler
.
persistent_load
=
prfactory
unpickler
.
persistent_load
=
prfactory
.
persistent_load
class_tuple
=
unpickler
.
load
()[
0
]
class_tuple
=
unpickler
.
load
()[
0
]
if
bad_class
(
class_tuple
):
if
bad_class
(
class_tuple
):
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
return
0
newstate
=
unpickler
.
load
()
newstate
=
unpickler
.
load
()
klass
=
_classFactory
(
class_tuple
[
0
],
class_tuple
[
1
])
klass
=
_classFactory
(
class_tuple
[
0
],
class_tuple
[
1
])
inst
=
klass
.
__basicnew__
()
inst
=
klass
.
__basicnew__
()
try
:
try
:
resolve
=
inst
.
_p_resolveConflict
resolve
=
inst
.
_p_resolveConflict
except
AttributeError
:
except
AttributeError
:
bad_classes
[
class_tuple
]
=
1
bad_classes
[
class_tuple
]
=
1
#traceback.print_exc()
#sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
return
0
return
0
old
=
state
(
self
,
oid
,
oldSerial
,
prfactory
)
old
=
state
(
self
,
oid
,
oldSerial
,
prfactory
)
committed
=
state
(
self
,
oid
,
committedSerial
,
prfactory
,
committedData
)
committed
=
state
(
self
,
oid
,
committedSerial
,
prfactory
,
committedData
)
resolved
=
resolve
(
old
,
committed
,
newstate
)
resolved
=
resolve
(
old
,
committed
,
newstate
)
file
=
StringIO
()
file
=
StringIO
()
pickler
=
Pickler
(
file
,
1
)
pickler
=
Pickler
(
file
,
1
)
pickler
.
persistent_id
=
persistent_id
pickler
.
persistent_id
=
persistent_id
pickler
.
dump
(
class_tuple
)
pickler
.
dump
(
class_tuple
)
pickler
.
dump
(
resolved
)
pickler
.
dump
(
resolved
)
#sys.stderr.write(' r%s ' % class_tuple[1]); sys.stderr.flush()
return
file
.
getvalue
(
1
)
return
file
.
getvalue
(
1
)
except
ConflictError
:
except
ConflictError
:
return
0
return
0
...
@@ -120,4 +112,4 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
...
@@ -120,4 +112,4 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
class
ConflictResolvingStorage
:
class
ConflictResolvingStorage
:
"Mix-in class that provides conflict resolution handling for storages"
"Mix-in class that provides conflict resolution handling for storages"
tryToResolveConflict
=
tryToResolveConflict
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