Commit 9fca9730 authored by Vincent Pelletier's avatar Vincent Pelletier

Make "notify" use "real" latest alarm report (it would be implicitely...

Make "notify" use "real" latest alarm report (it would be implicitely considered as incomplete since the alarm is still running).
Make sure consistent alarm report is used in "notify".

git-svn-id: 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e0ac27be
......@@ -434,7 +434,10 @@ class Alarm(XMLObject, PeriodicityMixin):
notification_mode = self.getAlarmNotificationMode()
if notification_mode == 'never':
if self.sense():
# Grab real latest result. Otherwise, we wuld chack n-1 execution as n is
# still considered running, and its result would be skipped.
active_process = self.getLastActiveProcess(include_active=True)
if self.sense(process=active_process):
prefix = 'ERROR'
if notification_mode != 'always':
......@@ -444,7 +447,7 @@ class Alarm(XMLObject, PeriodicityMixin):
candidate_list = self.getDestinationValueList()
if not candidate_list:
candidate_list = None
result_list = [x for x in self.getLastActiveProcess().getResultList() if x is not None]
result_list = [x for x in active_process.getResultList() if x is not None]
attachment_list = []
if len(result_list):
def sort_result_list(a, b):
......@@ -475,12 +478,15 @@ Alarm URL: %s
security.declareProtected(Permissions.View, 'getLastActiveProcess')
def getLastActiveProcess(self):
def getLastActiveProcess(self, include_active=False):
This returns the last active process finished. So it will
not returns the current one
limit = self.isActive() and 2 or 1
if include_active:
limit = 1
limit = self.isActive() and 2 or 1
active_process_list = self.getPortalObject().portal_catalog(
portal_type='Active Process', limit=limit,
sort_on=(('creation_date', 'DESC'), ),
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