comparison 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
comparison
equal deleted inserted replaced
4042:877145b4ba01 4043:9641ce286e07
1261 action_data, 1261 action_data,
1262 security_limit=C.NO_SECURITY_LIMIT, 1262 security_limit=C.NO_SECURITY_LIMIT,
1263 keep_id=None, 1263 keep_id=None,
1264 profile=C.PROF_KEY_NONE, 1264 profile=C.PROF_KEY_NONE,
1265 ): 1265 ):
1266 """Shortcut to bridge.action_new which generate and id and keep for retrieval 1266 """Shortcut to bridge.action_new which generate an id and keep for retrieval
1267 1267
1268 @param action_data(dict): action data (see bridge documentation) 1268 @param action_data(dict): action data (see bridge documentation)
1269 @param security_limit: %(doc_security_limit)s 1269 @param security_limit: %(doc_security_limit)s
1270 @param keep_id(None, unicode): if not None, used to keep action for differed 1270 @param keep_id(None, unicode): if not None, used to keep action for differed
1271 retrieval. Must be set to the callback_id. 1271 retrieval. The value will be used as callback_id, be sure to use an unique
1272 value.
1272 Action will be deleted after 30 min. 1273 Action will be deleted after 30 min.
1273 @param profile: %(doc_profile)s 1274 @param profile: %(doc_profile)s
1274 """ 1275 """
1275 id_ = str(uuid.uuid4())
1276 if keep_id is not None: 1276 if keep_id is not None:
1277 id_ = keep_id
1277 client = self.get_client(profile) 1278 client = self.get_client(profile)
1278 action_timer = reactor.callLater(60 * 30, self._kill_action, keep_id, client) 1279 action_timer = reactor.callLater(60 * 30, self._kill_action, keep_id, client)
1279 client.actions[keep_id] = (action_data, id_, security_limit, action_timer) 1280 client.actions[keep_id] = (action_data, id_, security_limit, action_timer)
1281 else:
1282 id_ = str(uuid.uuid4())
1280 1283
1281 self.bridge.action_new( 1284 self.bridge.action_new(
1282 data_format.serialise(action_data), id_, security_limit, profile 1285 data_format.serialise(action_data), id_, security_limit, profile
1283 ) 1286 )
1284 1287