[Erp5-report] r32880 jm - in /erp5/trunk/products/CMFActivity: ./ Activity/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Feb 19 18:56:21 CET 2010
Author: jm
Date: Fri Feb 19 18:56:20 2010
New Revision: 32880
URL: http://svn.erp5.org?rev=32880&view=rev
Log:
Improve notification in case of failed activity
* Change subject from "Failed Processing Activity" to
"Activity failed: <path>/<method>"
* The subject starts with "Pending activity already failed <failures> times:"
if CMFActivity is going to reexecute indefinitely.
* Drop the first line of the body. It was repeating the the subject.
* Add number of failures.
Modified:
erp5/trunk/products/CMFActivity/Activity/SQLBase.py
erp5/trunk/products/CMFActivity/ActivityTool.py
erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
Modified: erp5/trunk/products/CMFActivity/Activity/SQLBase.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLBase.py?rev=32880&r1=32879&r2=32880&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLBase.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLBase.py [utf8] Fri Feb 19 18:56:20 2010
@@ -171,13 +171,13 @@
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 @@
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,
Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=32880&r1=32879&r2=32880&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityTool.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/ActivityTool.py [utf8] Fri Feb 19 18:56:20 2010
@@ -310,7 +310,7 @@
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 @@
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 @@
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):
Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=32880&r1=32879&r2=32880&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] Fri Feb 19 18:56:20 2010
@@ -1562,7 +1562,7 @@
# 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 @@
# 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 @@
# 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):
More information about the Erp5-report
mailing list