(20250120) Safety Push.

This commit is contained in:
2025-01-20 14:13:36 +05:30
parent 851cfd457e
commit 1f8e13e1d5
3 changed files with 36 additions and 24 deletions
+8 -8
View File
@@ -545,7 +545,7 @@ def read_input(
def get_session_info(
key: str,
model: str = None,
controller: str = None,
session_func: str = None,
session_coro: str = None,
get: str = None,
@@ -560,12 +560,12 @@ def get_session_info(
PLEASE USE "ResponseModel" AS THE RETURNED VALUE OF THE API ENDPOINT IF YOU ARE USING THIS DECORATOR.
:param key: The key in either the 'inbound_data' or the 'inbound_headers' from which the session info will be
available. Examples: 'sessionToken' or 'X-Session-Token'.
:param model: The object from which the func/coro should be called. This could be the name of the variable holding
an instance of a class. Should be available in the scope of 'current_app'.
:param session_func: The synchronous func of the model to call. This can either be an independent function or a
:param controller: The object from which the func/coro should be called. This could be the name of the variable
holding an instance of a class. Should be available in the scope of 'current_app'.
:param session_func: The synchronous func of the controller to call. This can either be an independent function or a
class's method. Should be available in the scope of 'current_app'.
:param session_coro: The asynchronous func of the model to call. This can either be an independent function or a
class's method. Ignored if 'func' was provided. Should be available in the scope of 'current_app'.
:param session_coro: The asynchronous func of the controller to call. This can either be an independent function or
a class's method. Ignored if 'func' was provided. Should be available in the scope of 'current_app'.
:param get: The field inside the dict to get. Specify this in dot notation. The whole response will be returned as
is if this is null.
:param mandatory: If set to True, the API call will enforce session checking; and if a session is not found, the
@@ -593,12 +593,12 @@ def get_session_info(
# For synchronous functions:
if session_func:
if model: session_info = getattr(getattr(current_app, model), session_func)(session_id)
if controller: session_info = getattr(getattr(current_app, controller), session_func)(session_id)
else: session_info = getattr(current_app, session_func)(session_id)
# For asynchronous coroutines:
elif session_coro:
if model: session_info = await getattr(getattr(current_app, model), session_coro)(session_id)
if controller: session_info = await getattr(getattr(current_app, controller), session_coro)(session_id)
else: session_info = await getattr(current_app, session_coro)(session_id)
# If something goes wrong: