Mercurial > libervia-backend
diff sat/core/sat_main.py @ 4043:9641ce286e07
core (main): if `keep_id` is set in `action_new`, use it as `action_id`
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 15 May 2023 16:20:58 +0200 |
parents | 2594e1951cf7 |
children |
line wrap: on
line diff
--- a/sat/core/sat_main.py Mon May 15 16:20:50 2023 +0200 +++ b/sat/core/sat_main.py Mon May 15 16:20:58 2023 +0200 @@ -1263,20 +1263,23 @@ keep_id=None, profile=C.PROF_KEY_NONE, ): - """Shortcut to bridge.action_new which generate and id and keep for retrieval + """Shortcut to bridge.action_new which generate an id and keep for retrieval @param action_data(dict): action data (see bridge documentation) @param security_limit: %(doc_security_limit)s @param keep_id(None, unicode): if not None, used to keep action for differed - retrieval. Must be set to the callback_id. + retrieval. The value will be used as callback_id, be sure to use an unique + value. Action will be deleted after 30 min. @param profile: %(doc_profile)s """ - id_ = str(uuid.uuid4()) if keep_id is not None: + id_ = keep_id client = self.get_client(profile) action_timer = reactor.callLater(60 * 30, self._kill_action, keep_id, client) client.actions[keep_id] = (action_data, id_, security_limit, action_timer) + else: + id_ = str(uuid.uuid4()) self.bridge.action_new( data_format.serialise(action_data), id_, security_limit, profile