Mercurial > libervia-backend
comparison sat/tools/trigger.py @ 2650:3a8e7ec4648a
tools (trigger, async_trigger): added no_cancel argument to point and asyncPoint when a trigger must not be cancellable
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 11 Aug 2018 18:24:52 +0200 |
parents | 56f94936df1e |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2649:b06af19c851f | 2650:3a8e7ec4648a |
---|---|
89 def point(self, point_name, *args, **kwargs): | 89 def point(self, point_name, *args, **kwargs): |
90 """This put a trigger point | 90 """This put a trigger point |
91 | 91 |
92 All the triggers for that point will be run | 92 All the triggers for that point will be run |
93 @param point_name: name of the trigger point | 93 @param point_name: name of the trigger point |
94 @param *args: args to transmit to trigger | |
95 @param *kwargs: kwargs to transmit to trigger | |
96 if "triggers_no_cancel" is present, it will be popup out | |
97 when set to True, this argument don't let triggers stop | |
98 the workflow | |
94 @return: True if the action must be continued, False else | 99 @return: True if the action must be continued, False else |
95 """ | 100 """ |
96 if point_name not in self.__triggers: | 101 if point_name not in self.__triggers: |
97 return True | 102 return True |
98 | 103 |
104 can_cancel = not kwargs.pop('triggers_no_cancel', False) | |
105 | |
99 for priority, trigger in self.__triggers[point_name]: | 106 for priority, trigger in self.__triggers[point_name]: |
100 try: | 107 try: |
101 if not trigger(*args, **kwargs): | 108 if not trigger(*args, **kwargs) and can_cancel: |
102 return False | 109 return False |
103 except SkipOtherTriggers: | 110 except SkipOtherTriggers: |
104 break | 111 break |
105 return True | 112 return True |
106 | 113 |