diff --git a/product/CMFActivity/Activity/SQLBase.py b/product/CMFActivity/Activity/SQLBase.py index 7e9ea825ad0dbf3bd73f23eef7bbdbd732e8b287..a0613cf9329576981a18d220e9672c78c01b9f77 100644 --- a/product/CMFActivity/Activity/SQLBase.py +++ b/product/CMFActivity/Activity/SQLBase.py @@ -171,13 +171,13 @@ class SQLBase: retry = m.line.retry if max_retry is not None and retry >= max_retry: # Always notify when we stop retrying. - notify_user_list.append(m) + notify_user_list.append((m, False)) final_error_uid_list.append(uid) continue # In case of infinite retry, notify the user # when the default limit is reached. if max_retry is None and retry == m.__class__.max_retry: - notify_user_list.append(m) + notify_user_list.append((m, True)) delay = m.delay if delay is None: # By default, make delay quadratic to the number of retries. @@ -235,8 +235,8 @@ class SQLBase: else: self._log(TRACE, 'Freed messages %r' % make_available_uid_list) try: - for m in notify_user_list: - m.notifyUser(activity_tool) + for m, retry in notify_user_list: + m.notifyUser(activity_tool, retry) except: # Notification failures must not cause this method to raise. self._log(WARNING, diff --git a/product/CMFActivity/ActivityTool.py b/product/CMFActivity/ActivityTool.py index cdb7c8ede4b93fe4486e6bf246be99500c9cc4c4..4a1ad6b60d652543239c9dfbb9a52bd060e2b82c 100644 --- a/product/CMFActivity/ActivityTool.py +++ b/product/CMFActivity/ActivityTool.py @@ -310,7 +310,7 @@ class Message(BaseMessage): def getDependentMessageList(self, activity, activity_tool): return activity.getDependentMessageList(activity_tool, self, **self.activity_kw) - def notifyUser(self, activity_tool, message="Failed Processing Activity"): + def notifyUser(self, activity_tool, retry=False): """Notify the user that the activity failed.""" portal = activity_tool.getPortalObject() user_email = portal.getProperty('email_to_address', @@ -322,13 +322,18 @@ class Message(BaseMessage): if self.call_traceback: call_traceback = 'Created at:\n%s' % self.call_traceback + fail_count = self.line.retry + 1 + if retry: + message = "Pending activity already failed %s times" % fail_count + else: + message = "Activity failed" + path = '/'.join(self.object_path) mail_text = """From: %s <%s> To: %s -Subject: %s - -%s +Subject: %s: %s/%s Node: %s +Failures: %s User name: %r Document: %s Method: %s @@ -339,10 +344,10 @@ Named Parameters: %r Exception: %s %s %s -""" % (email_from_name, activity_tool.email_from_address, - user_email, message, message, - activity_tool.getCurrentNode(), self.user_name, - '/'.join(self.object_path), self.method_id, self.args, self.kw, +""" % (email_from_name, activity_tool.email_from_address, user_email, + message, path, self.method_id, + activity_tool.getCurrentNode(), fail_count, + self.user_name, path, self.method_id, self.args, self.kw, call_traceback, self.exc_type, self.exc_value, self.traceback) if isinstance(mail_text, unicode): diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index 7d6b05b5b01e9fc22dfd100791d3ffc1d22ae1f5..92bf2648873610839163215de086c6a4649b7601 100644 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -1562,7 +1562,7 @@ class TestCMFActivity(ERP5TypeTestCase): # Monkey patch Message not to send failure notification emails from Products.CMFActivity.ActivityTool import Message originalNotifyUser = Message.notifyUser - def notifyUserSilent(self, activity_tool, message=''): + def notifyUserSilent(self, *args, **kw): pass Message.notifyUser = notifyUserSilent @@ -1645,7 +1645,7 @@ class TestCMFActivity(ERP5TypeTestCase): # Monkey patch Message not to send failure notification emails from Products.CMFActivity.ActivityTool import Message originalNotifyUser = Message.notifyUser - def notifyUserSilent(self, activity_tool, message=''): + def notifyUserSilent(self, *args, **kw): pass Message.notifyUser = notifyUserSilent @@ -2324,7 +2324,7 @@ class TestCMFActivity(ERP5TypeTestCase): # monkeypatch method. notification_done = [] from Products.CMFActivity.ActivityTool import Message - def fake_notifyUser(self, activity_tool): + def fake_notifyUser(self, *args, **kw): notification_done.append(True) original_notifyUser = Message.notifyUser def failingMethod(self):