ConflictError on Zope 2.12 is a new-style class, adjust the type-check

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31892 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f7fd311
......@@ -324,13 +324,13 @@ class SQLDict(RAMDict, SQLBase):
def finalizeMessageExecution(self, activity_tool, message_uid_priority_list, uid_to_duplicate_uid_list_dict):
"""
If everything was fine, delete all messages.
If anything failed, make successfull messages available (if any), and
If anything failed, make successful messages available (if any), and
the following rules apply to failed messages:
- Failures due to ConflictErrors cause messages to be postponed,
but their priority is *not* increased.
- Failures of messages already above maximum priority cause them to
be put in a permanent-error state.
- In all other cases, priotity is increased and message is delayed.
- In all other cases, priority is increased and message is delayed.
"""
def makeMessageListAvailable(uid_list):
self.makeMessageListAvailable(activity_tool=activity_tool, uid_list=uid_list)
......@@ -353,7 +353,11 @@ class SQLDict(RAMDict, SQLBase):
# Should duplicate messages follow strictly the original message, or
# should they be just made available again ?
make_available_uid_list.extend(uid_to_duplicate_uid_list_dict.get(uid, []))
if type(m.exc_type) is ClassType and \
# BACK: Only exceptions can be classes in Python 2.6.
# Once we drop support for Python 2.4,
# please, remove the "type(m.exc_type) is type(ConflictError)" check
# and leave only the "issubclass(m.exc_type, ConflictError)" check.
if type(m.exc_type) is type(ConflictError) and \
issubclass(m.exc_type, ConflictError):
delay_uid_list.append(uid)
elif priority > MAX_PRIORITY:
......
......@@ -217,7 +217,11 @@ class SQLQueue(RAMQueue, SQLBase):
if m.getExecutionState() == MESSAGE_EXECUTED:
deletable_uid_list.append(uid)
elif m.getExecutionState() == MESSAGE_NOT_EXECUTED:
if type(m.exc_type) is ClassType and \
# BACK: Only exceptions can be classes in Python 2.6.
# Once we drop support for Python 2.4,
# please, remove the "type(m.exc_type) is type(ConflictError)" check
# and leave only the "issubclass(m.exc_type, ConflictError)" check.
if type(m.exc_type) is type(ConflictError) and \
issubclass(m.exc_type, ConflictError):
delay_uid_list.append(uid)
elif priority > MAX_PRIORITY:
......
......@@ -716,16 +716,15 @@ class TestCMFActivity(ERP5TypeTestCase):
self.assertEquals(len(activity_tool.getMessageList()), 0)
# Monkey patch Organisation to induce conflict errors artificially.
o.foobar = 0
def induceConflictErrors(self, limit):
if self.__class__.current_num_conflict_errors < limit:
self.__class__.current_num_conflict_errors += 1
raise ConflictError
else:
foobar = getattr(self, 'foobar', 0)
setattr(self, 'foobar', foobar + 1)
self.foobar += 1
Organisation.induceConflictErrors = induceConflictErrors
setattr(o, 'foobar', 0)
# Test some range of conflict error occurences.
for i in xrange(10):
Organisation.current_num_conflict_errors = 0
......@@ -733,7 +732,7 @@ class TestCMFActivity(ERP5TypeTestCase):
get_transaction().commit()
self.flushAllActivities(silent = 1, loop_size = i + 10)
self.assertEquals(len(activity_tool.getMessageList()), 0)
self.assertEqual(getattr(o, 'foobar', 0), 10)
self.assertEqual(o.foobar, 10)
def TryConflictErrorsWhileValidating(self, activity):
"""Try to execute active objects which may throw conflict errors
......
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