def roles_required(*roles):
 def wrapper(fn):
  @wraps(fn)
  def decorated_view(*args, **kwargs):
   perms = [Permission(RoleNeed(role)) for role in roles]
   for perm in perms:
    if (not perm.can()):
     if _security._unauthorized_callback:
      return _security._unauthorized_callback()
     else:
      return _get_unauthorized_view()
   return fn(*args, **kwargs)
  return decorated_view
 return wrapper

def roles_required ( * roles ) : def wrapper ( fn ) : @ wraps ( fn ) def decorated_view ( * args , ** kwargs ) : perms = [ Permission ( RoleNeed ( role ) ) for role in roles ] for perm in perms : if ( not perm . can ( ) ) : if _security . _unauthorized_callback : return _security . _unauthorized_callback ( ) else : return _get_unauthorized_view ( ) return fn ( * args , ** kwargs ) return decorated_view return wrapper
decorator which specifies that a user must have all the specified roles .