Commit 32208eb8 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Allow activeSense to accept an optionnal parameter to active sense method. The same for notify.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30513 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c4e4726e
...@@ -287,7 +287,7 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -287,7 +287,7 @@ class Alarm(XMLObject, PeriodicityMixin):
return self.hasActivity(only_valid=1) return self.hasActivity(only_valid=1)
security.declareProtected(Permissions.AccessContentsInformation, 'activeSense') security.declareProtected(Permissions.AccessContentsInformation, 'activeSense')
def activeSense(self, fixit=0): def activeSense(self, fixit=0, params=None):
""" """
This method launches the sensing process as activities. This method launches the sensing process as activities.
It is intended to launch a very long process made It is intended to launch a very long process made
...@@ -326,15 +326,18 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -326,15 +326,18 @@ class Alarm(XMLObject, PeriodicityMixin):
kw = {} kw = {}
method = getattr(self, method_id) method = getattr(self, method_id)
name_list = method.func_code.co_varnames name_list = method.func_code.co_varnames
if 'fixit' in name_list or (method.func_defaults is not None if 'params' in name_list or (method.func_defaults is not None
and len(method.func_defaults) < len(name_list)): and len(method.func_defaults) < len(name_list)):
# New New API
getattr(self.activate(tag=tag), method_id)(fixit=fixit, tag=tag, params=params)
elif 'fixit' in name_list:
# New API - also if variable number of named parameters # New API - also if variable number of named parameters
getattr(self.activate(tag=tag), method_id)(fixit=fixit, tag=tag) getattr(self.activate(tag=tag), method_id)(fixit=fixit, tag=tag)
else: else:
# Old API # Old API
getattr(self.activate(tag=tag), method_id)() getattr(self.activate(tag=tag), method_id)()
if self.isAlarmNotificationMode(): if self.isAlarmNotificationMode():
self.activate(after_tag=tag).notify(include_active=True) self.activate(after_tag=tag).notify(include_active=True, params=params)
finally: finally:
# Restore the original user. # Restore the original user.
setSecurityManager(sm) setSecurityManager(sm)
...@@ -439,7 +442,7 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -439,7 +442,7 @@ class Alarm(XMLObject, PeriodicityMixin):
return self.activeSense(fixit=1) return self.activeSense(fixit=1)
security.declareProtected(Permissions.ManagePortal, 'notify') security.declareProtected(Permissions.ManagePortal, 'notify')
def notify(self, include_active=False): def notify(self, include_active=False, params=None):
""" """
This method is called to notify people that some alarm has This method is called to notify people that some alarm has
been sensed. Notification consists of sending an email been sensed. Notification consists of sending an email
...@@ -461,7 +464,8 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -461,7 +464,8 @@ class Alarm(XMLObject, PeriodicityMixin):
method_id = self.getNotificationMethodId() method_id = self.getNotificationMethodId()
if method_id: if method_id:
getattr(self, method_id)(process=active_process, getattr(self, method_id)(process=active_process,
sense_result=sense_result) sense_result=sense_result,
params=params)
return return
if sense_result: if sense_result:
......
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