# HG changeset patch # User Goffi # Date 1350840518 -7200 # Node ID 5431136501ab836a84d25b94b90eaae475f3d132 # Parent 0bb595eff25b09568de486db790b189b607d3a5c core: Triggers can now frobid other triggers execution if a trigger raise SkipOtherTriggers exception, normal behaviour will occure, skipping other triggers diff -r 0bb595eff25b -r 5431136501ab src/tools/misc.py --- a/src/tools/misc.py Sun Oct 21 16:40:19 2012 +0200 +++ b/src/tools/misc.py Sun Oct 21 19:28:38 2012 +0200 @@ -26,6 +26,11 @@ 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 @@ 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