Commit 8cc7d984 authored by Julien Muchembled's avatar Julien Muchembled

Alarm: use a tag that doesn't conflict with other alarms

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34777 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 876f81bc
...@@ -267,6 +267,16 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -267,6 +267,16 @@ class Alarm(XMLObject, PeriodicityMixin):
""" """
return self.hasActivity(only_valid=1) return self.hasActivity(only_valid=1)
def __getTag(self, new):
# Tag is generated from portal_ids so that it can be retrieved
# later when creating an active process for example
portal_ids = self.getPortalObject().portal_ids
if new:
id = portal_ids.generateNewId(id_generator='uid', id_group=self.getId())
else:
id = portal_ids.getLastLengthGeneratedId(id_group=self.getId())
return '%s_%s' % (self.getRelativeUrl(), id)
security.declareProtected(Permissions.AccessContentsInformation, 'activeSense') security.declareProtected(Permissions.AccessContentsInformation, 'activeSense')
def activeSense(self, fixit=0, params=None): def activeSense(self, fixit=0, params=None):
""" """
...@@ -299,11 +309,9 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -299,11 +309,9 @@ class Alarm(XMLObject, PeriodicityMixin):
if method_id not in (None, ''): if method_id not in (None, ''):
# A tag is provided as a parameter in order to be # A tag is provided as a parameter in order to be
# able to notify the user after all processes are ended # able to notify the user after all processes are ended
# Tag is generated from portal_ids so that it can be retrieved
# later when creating an active process for example
# We do some inspection to keep compatibility # We do some inspection to keep compatibility
# (because fixit and tag were not set previously) # (because fixit and tag were not set previously)
tag = str(self.portal_ids.generateNewId(id_generator='uid', id_group=self.getId())) tag = self.__getTag(True)
method = getattr(self, method_id) method = getattr(self, method_id)
func_code = method.func_code func_code = method.func_code
try: try:
...@@ -526,10 +534,8 @@ Alarm Tool Node: %s ...@@ -526,10 +534,8 @@ Alarm Tool Node: %s
new results, then this process will be added to the list new results, then this process will be added to the list
of processes of processes
""" """
tag = self.portal_ids.getLastLengthGeneratedId(id_group=self.getId())
activate_kw = kw.get('activate_kw', {}) activate_kw = kw.get('activate_kw', {})
if tag is not None: activate_kw.setdefault('tag', self.__getTag(False))
activate_kw.setdefault('tag', str(tag))
portal_activities = getToolByName(self,'portal_activities') portal_activities = getToolByName(self,'portal_activities')
active_process = portal_activities.newActiveProcess(start_date=DateTime(), active_process = portal_activities.newActiveProcess(start_date=DateTime(),
causality_value=self, causality_value=self,
......
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