def required_perms(*req_perms):
    """
       Decorator applied to functions requiring caller to possess permission
       Takes args tuple of required perms and raises PermissionsError
       via check_perm if these are not a subset of user perms
    """
    def dec_wrapper(wfunc):
        @wraps(wfunc)
        def wrapped(*args, **kwargs):
            user_id = kwargs.get("user_id")
            for perm in req_perms:
                check_perm(user_id, perm)

            return wfunc(*args, **kwargs)

        return wrapped
    return dec_wrapper
def required_perms ( * req_perms ) : def dec_wrapper ( wfunc ) : @ wraps ( wfunc ) def wrapped ( * args , ** kwargs ) : user_id = kwargs . get ( "user_id" ) for perm in req_perms : check_perm ( user_id , perm ) return wfunc ( * args , ** kwargs ) return wrapped return dec_wrapper
Decorator applied to functions requiring caller to possess permission
       Takes args tuple of required perms and raises PermissionsError
       via check_perm if these are not a subset of user perms