core: Triggers can now frobid other triggers execution

if a trigger raise SkipOtherTriggers exception, normal behaviour will occure, skipping other triggers
This commit is contained in:
Goffi 2012-10-21 19:28:38 +02:00
commit d7ec36d6db

View file

@ -26,6 +26,11 @@ from logging import debug, info, error
class TriggerException(Exception):
pass
class SkipOtherTriggers(Exception):
""" Exception to raise if normal behaviour must be followed instead of
followind triggers list """
pass
class TriggerManager:
"""This class manage triggers: code which interact to change de behaviour of SàT"""
@ -62,7 +67,10 @@ class TriggerManager:
return True
for priority,trigger in self.__triggers[point_name]:
if not trigger(*args, **kwargs):
return False
try:
if not trigger(*args, **kwargs):
return False
except SkipOtherTriggers:
break
return True