[Erp5-report] r12021 - in /erp5/trunk/products/CMFActivity: Activity/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jan 11 14:45:03 CET 2007
Author: yo
Date: Thu Jan 11 14:45:01 2007
New Revision: 12021
URL: http://svn.erp5.org?rev=12021&view=rev
Log:
This fixes a problem that SQLQueue increases the priority of a message even for conflict errors.
Modified:
erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=12021&r1=12020&r2=12021&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Thu Jan 11 14:45:01 2007
@@ -33,7 +33,7 @@
from Queue import VALID, INVALID_ORDER, INVALID_PATH, EXCEPTION, MAX_PROCESSING_TIME, VALIDATION_ERROR_DELAY
from Products.CMFActivity.ActiveObject import DISTRIBUTABLE_STATE, INVOKE_ERROR_STATE, VALIDATE_ERROR_STATE
from ZODB.POSException import ConflictError
-from types import StringType
+from types import StringType, ClassType
import sys
try:
@@ -159,9 +159,15 @@
LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass
- if line.priority > MAX_PRIORITY:
+ if type(m.exc_type) is ClassType \
+ and issubclass(m.exc_type, ConflictError):
+ activity_tool.SQLQueue_setPriority(uid = line.uid,
+ date = next_processing_date,
+ priority = line.priority)
+ elif line.priority > MAX_PRIORITY:
# This is an error
- activity_tool.SQLQueue_assignMessage(uid=line.uid, processing_node = INVOKE_ERROR_STATE)
+ activity_tool.SQLQueue_assignMessage(uid = line.uid,
+ processing_node = INVOKE_ERROR_STATE)
# Assign message back to 'error' state
m.notifyUser(activity_tool) # Notify Error
else:
Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=12021&r1=12020&r2=12021&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py Thu Jan 11 14:45:01 2007
@@ -53,6 +53,7 @@
from Acquisition import aq_base, aq_inner
from zLOG import LOG
import time
+from ZODB.POSException import ConflictError
try:
from transaction import get as get_transaction
@@ -642,6 +643,36 @@
self.assertEquals(o.getTitle(), 'a')
self.assertEquals(portal_activities.countMessageWithTag('toto'), 0)
+ def TryConflictErrorsWhileProcessing(self, activity):
+ """Try to execute active objects which may throw conflict errors
+ while processing, and check if they are still executed."""
+ # Make sure that no active object is installed.
+ activity_tool = self.getPortal().portal_activities
+ activity_tool.manageClearActivities(keep=0)
+
+ # Need an object.
+ organisation_module = self.getOrganisationModule()
+ if not organisation_module.hasContent(self.company_id):
+ organisation_module.newContent(id=self.company_id)
+ o = organisation_module._getOb(self.company_id)
+ get_transaction().commit()
+ self.flushAllActivities(silent = 1, loop_size = 10)
+ self.assertEquals(len(activity_tool.getMessageList()), 0)
+
+ # Monkey patch Organisation to induce conflict errors artificially.
+ def induceConflictErrors(self, limit):
+ if self.__class__.current_num_conflict_errors < limit:
+ self.__class__.current_num_conflict_errors += 1
+ raise ConflictError
+ Organisation.induceConflictErrors = induceConflictErrors
+
+ # Test some range of conflict error occurences.
+ for i in xrange(10):
+ Organisation.current_num_conflict_errors = 0
+ o.activate(activity = activity).induceConflictErrors(i)
+ get_transaction().commit()
+ self.flushAllActivities(silent = 1, loop_size = i + 10)
+ self.assertEquals(len(activity_tool.getMessageList()), 0)
def test_01_DeferedSetTitleSQLDict(self, quiet=0, run=run_all_test):
# Test if we can add a complete sales order
@@ -1409,6 +1440,28 @@
get_transaction().commit()
self.assertEquals(len(activity_tool.getMessageList()), 0)
+ def test_68_TestConflictErrorsWhileProcessingWithSQLDict(self, quiet=0, run=run_all_test):
+ """
+ Test if conflict errors spoil out active objects with SQLDict.
+ """
+ if not run: return
+ if not quiet:
+ message = '\nTest Conflict Errors While Processing With SQLDict'
+ ZopeTestCase._print(message)
+ LOG('Testing... ', 0, message)
+ self.TryConflictErrorsWhileProcessing('SQLDict')
+
+ def test_69_TestConflictErrorsWhileProcessingWithSQLQueue(self, quiet=0, run=run_all_test):
+ """
+ Test if conflict errors spoil out active objects with SQLQueue.
+ """
+ if not run: return
+ if not quiet:
+ message = '\nTest Conflict Errors While Processing With SQLQueue'
+ ZopeTestCase._print(message)
+ LOG('Testing... ', 0, message)
+ self.TryConflictErrorsWhileProcessing('SQLQueue')
+
if __name__ == '__main__':
framework()
More information about the Erp5-report
mailing list