Commit 3fc22579 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: sortKey() must be a string as comparison between str and None/int/tuple now raises TypeError.

And Zope4 now mandates it to be a string ({Shared.DC.ZRDB.TM.TM,ITransactionManager}.sortKey()).
parent 14111103
...@@ -75,4 +75,4 @@ class ActivityBuffer(TM): ...@@ -75,4 +75,4 @@ class ActivityBuffer(TM):
def sortKey(self, *ignored): def sortKey(self, *ignored):
"""Activities must be finished before databases commit transactions.""" """Activities must be finished before databases commit transactions."""
return -1 return '-1'
...@@ -34,7 +34,7 @@ from Acquisition import aq_parent ...@@ -34,7 +34,7 @@ from Acquisition import aq_parent
# If the sort order below doesn't work, we cannot guarantee the sort key # If the sort order below doesn't work, we cannot guarantee the sort key
# used below will actually result in the activity connection being committed # used below will actually result in the activity connection being committed
# after the ZODB and Catalog data. # after the ZODB and Catalog data.
assert None < 0 < '' < (), "Cannot guarantee commit of activities comes after the appropriate data" assert '\x00' < '-1' < '0' < '1' < '\xff', "Cannot guarantee commit of activities comes after the appropriate data"
manage_addActivityConnectionForm = HTMLFile('dtml/connectionAdd', globals()) manage_addActivityConnectionForm = HTMLFile('dtml/connectionAdd', globals())
...@@ -66,4 +66,4 @@ InitializeClass(ActivityConnection) ...@@ -66,4 +66,4 @@ InitializeClass(ActivityConnection)
class ActivityDB(DB): class ActivityDB(DB):
_sort_key = (0,) _sort_key = '\xff'
...@@ -70,7 +70,7 @@ class TransactionalVariable(dict): ...@@ -70,7 +70,7 @@ class TransactionalVariable(dict):
_unregistered = True _unregistered = True
def sortKey(self): def sortKey(self):
return None return '\x00'
commit = tpc_vote = tpc_begin = tpc_abort = lambda self, transaction: None commit = tpc_vote = tpc_begin = tpc_abort = lambda self, transaction: None
...@@ -128,7 +128,7 @@ class TransactionalResource(object): ...@@ -128,7 +128,7 @@ class TransactionalResource(object):
return not (args in tv or tv.add(args)) return not (args in tv or tv.add(args))
def sortKey(self): def sortKey(self):
return 1 return '1'
abort = commit = tpc_vote = tpc_begin = tpc_finish = tpc_abort = \ abort = commit = tpc_vote = tpc_begin = tpc_finish = tpc_abort = \
lambda self, transaction: None lambda self, transaction: None
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment