[Erp5-report] r31892 leonardo - in /erp5/trunk/products/CMFActivity: Activity/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 21 20:26:48 CET 2010


Author: leonardo
Date: Thu Jan 21 20:26:48 2010
New Revision: 31892

URL: http://svn.erp5.org?rev=31892&view=rev
Log:
ConflictError on Zope 2.12 is a new-style class, adjust the type-check

Modified:
    erp5/trunk/products/CMFActivity/Activity/SQLDict.py
    erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
    erp5/trunk/products/CMFActivity/tests/testCMFActivity.py

Modified: erp5/trunk/products/CMFActivity/Activity/SQLDict.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLDict.py?rev=31892&r1=31891&r2=31892&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLDict.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLDict.py [utf8] Thu Jan 21 20:26:48 2010
@@ -324,13 +324,13 @@
   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 @@
         # 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:

Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=31892&r1=31891&r2=31892&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py [utf8] Thu Jan 21 20:26:48 2010
@@ -217,7 +217,11 @@
       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:

Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=31892&r1=31891&r2=31892&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] Thu Jan 21 20:26:48 2010
@@ -716,16 +716,15 @@
     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 @@
       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




More information about the Erp5-report mailing list