changeset 525:5431136501ab

core: Triggers can now frobid other triggers execution if a trigger raise SkipOtherTriggers exception, normal behaviour will occure, skipping other triggers
author Goffi <goffi@goffi.org>
date Sun, 21 Oct 2012 19:28:38 +0200
parents 0bb595eff25b
children d67f0ce83530
files src/tools/misc.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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