portal = context.getPortalObject()
alarm_tool = portal.portal_alarms

if alarm_tool.isSubscribed() and len(alarm_id_list):
  # No alarm tool is not subscribed, respect this choice and do not activate any alarm

  tag = "%s-%s" % (script.id, context.getRelativeUrl())
  if must_reindex_context:
    context.reindexObject(activate_kw={'tag': tag})

  for alarm_id in alarm_id_list:
    alarm = alarm_tool.restrictedTraverse(alarm_id)
    if alarm.isEnabled():
      # do nothing if the alarm is not enabled

      if alarm.isActive():
        # Wait for the previous alarm run to be finished
        context.activate(after_path=alarm.getPath()).Base_reindexAndSenseAlarm([alarm_id], must_reindex_context=False)
      else:
        # wait for the context to be reindexed before activating the alarm
        # ROMAIN: SQLQueue is used, because I'm not sure if SQLDict drop activities with different after_tag
        alarm.activate(queue='SQLQueue', after_tag=tag).activeSense()
