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:
parent
4e1905c238
commit
d7ec36d6db
1 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue