From 96b4e314a920eae7f52037152c86dcdafdf843da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 20 Jul 2018 14:39:23 +0200 Subject: [PATCH] Add 'in_accepted_state' to fsm_update messages --- lib/tfw/components/fsm_managing_event_handler.py | 4 +++- lib/tfw/event_handler_base.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tfw/components/fsm_managing_event_handler.py b/lib/tfw/components/fsm_managing_event_handler.py index 4e2c97f..ee95c6f 100644 --- a/lib/tfw/components/fsm_managing_event_handler.py +++ b/lib/tfw/components/fsm_managing_event_handler.py @@ -59,8 +59,10 @@ class FSMUpdater: for trigger in self.fsm.get_triggers(self.fsm.state) ] last_trigger = self.fsm.trigger_history[-1] if self.fsm.trigger_history else None + in_accepted_state = state in self.fsm.accepted_states return { 'current_state': state, 'valid_transitions': valid_transitions, - 'last_trigger': last_trigger + 'last_trigger': last_trigger, + 'in_accepted_state': in_accepted_state } diff --git a/lib/tfw/event_handler_base.py b/lib/tfw/event_handler_base.py index fb99748..aaf408c 100644 --- a/lib/tfw/event_handler_base.py +++ b/lib/tfw/event_handler_base.py @@ -116,6 +116,7 @@ class FSMAwareEventHandler(EventHandlerBase, ABC): super().__init__(key) self.subscribe('fsm_update') self.fsm_state = None + self.in_accepted_state = False self._auth_key = KeyManager().auth_key def dispatch_handling(self, message): @@ -132,6 +133,7 @@ class FSMAwareEventHandler(EventHandlerBase, ABC): if self.fsm_state != new_state: self.handle_fsm_step(self.fsm_state, new_state, trigger) self.fsm_state = new_state + self.in_accepted_state = message['data']['in_accepted_state'] except KeyError: LOG.error('Invalid fsm_update message received!')