Commit 580dc6d8 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add support for configuring notification by providing a method id. Otherwise,...

Add support for configuring notification by providing a method id. Otherwise, the message is hardcoded, and may not be customized.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30318 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ac016c58
......@@ -449,12 +449,23 @@ class Alarm(XMLObject, PeriodicityMixin):
# Grab real latest result. Otherwise, we would check n-1 execution as n is
# still considered running, and its result would be skipped.
active_process = self.getLastActiveProcess(include_active=include_active)
if self.sense(process=active_process):
sense_result = self.sense(process=active_process)
if not sense_result and notification_mode != 'always':
return
# If a notification method is specified explicitly, call it instead of
# using the default notification.
method_id = self.getNotificationMethodId()
if method_id:
getattr(self, method_id)(process=active_process,
sense_result=sense_result)
return
if sense_result:
prefix = 'ERROR'
else:
if notification_mode != 'always':
return
prefix = 'INFO'
notification_tool = getToolByName(self, 'portal_notifications')
candidate_list = self.getDestinationValueList()
if not candidate_list:
......
......@@ -50,6 +50,10 @@ class Alarm:
'description' : 'the method used to solve problems if any.',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'notification_method_id',
'description' : 'the method used to notify results.',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'alarm_notification_mode',
'description' : 'defines the notification mode of an Alarm.'
'Never, on sense or always.',
......
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