def check_role(*roles, **args_map):
    """
    It's just like has_role, but it's a decorator. And it'll check request.user
    """
    def f1(func, roles=roles):
        @wraps(func)
        def f2(*args, **kwargs):
            from uliweb import request, error
            
            arguments = {}
            for k, v in args_map.items():
                if v in kwargs:
                    arguments[k] = kwargs[v]
            if not has_role(request.user, *roles, **arguments):
                error(_("You have no roles to visit this page."))
            return func(*args, **kwargs)
        return f2
    return f1
def check_role ( * roles , ** args_map ) : def f1 ( func , roles = roles ) : @ wraps ( func ) def f2 ( * args , ** kwargs ) : from uliweb import request , error arguments = { } for k , v in args_map . items ( ) : if v in kwargs : arguments [ k ] = kwargs [ v ] if not has_role ( request . user , * roles , ** arguments ) : error ( _ ( "You have no roles to visit this page." ) ) return func ( * args , ** kwargs ) return f2 return f1
It's just like has_role, but it's a decorator. And it'll check request.user