def check_session_aspect(func, *args, **kwargs):
"""
The authentication aspect code, provides an aspect for the aop_check_session decorator
"""
# Get a list of the names of the non-keyword arguments
_argument_specifications = getfullargspec(func)
try:
# Try and find _session_id
arg_idx = _argument_specifications.args.index("_session_id")
except:
raise Exception("Authentication aspect for \"" + func.__name__ + "\": No _session_id parameter")
# Check if the session is valid.
_user = check_session(args[arg_idx])
# Call the function and set the _user parameter, if existing.
return alter_function_parameter_and_call(func, args, kwargs, '_user', _user)
评论列表
文章目录