Commit 75ca7a2d authored by Jérome Perrin's avatar Jérome Perrin

Revert "py3: sortKey() must be a string as comparison between str and...

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

This reverts commit 192c2000.

This commit introduced a test failure with testCommitOrder
testInvalidationBug.TestInvalidationBug [1]

    Traceback (most recent call last):
      File "Products/ERP5/tests/testInvalidationBug.py", line 93, in testCommitOrder
        self.assertEqual(result_list[1], [0,0])  # activity buffer first
    AssertionError: Lists differ: [1, 0] != [0, 0]

    First differing element 0:
    1
    0

    - [1, 0]
    ?  ^

    + [0, 0]
    ?  ^

That commit was apparently in the good direction, because transaction
API specifies that sortKey must return string

https://github.com/zopefoundation/transaction/blob/6cf10102948a8f4e36092a9b402e3859d6db4ccd/CHANGES.rst#141-2013-02-20
https://github.com/zopefoundation/transaction/blob/33448417ab526327757f05e23b1884786c805629/src/transaction/interfaces.py#L524-L534
parent 8f56e49c
...@@ -76,4 +76,4 @@ class ActivityBuffer(TM): ...@@ -76,4 +76,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 '\x00' < '-1' < '0' < '1' < '\xff', "Cannot guarantee commit of activities comes after the appropriate data" assert None < 0 < '' < (), "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 = '\xff' _sort_key = (0,)
...@@ -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 '\x00' return None
commit = tpc_vote = tpc_begin = tpc_abort = lambda self, transaction: None commit = tpc_vote = tpc_begin = tpc_abort = lambda self, transaction: None
...@@ -127,7 +127,7 @@ class TransactionalResource(object): ...@@ -127,7 +127,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