def must_have_permission(permission):
 def wrapper(func):
  @functools.wraps(func)
  def wrapped(*args, **kwargs):
   _inject_nodes(kwargs)
   node = kwargs['node']
   kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)
   user = kwargs['auth'].user
   if (user is None):
    raise HTTPError(http.UNAUTHORIZED)
   if (not node.has_permission(user, permission)):
    raise HTTPError(http.FORBIDDEN)
   return func(*args, **kwargs)
  return wrapped
 return wrapper

def must_have_permission ( permission ) : def wrapper ( func ) : @ functools . wraps ( func ) def wrapped ( * args , ** kwargs ) : _inject_nodes ( kwargs ) node = kwargs [ 'node' ] kwargs [ 'auth' ] = Auth . from_kwargs ( request . args . to_dict ( ) , kwargs ) user = kwargs [ 'auth' ] . user if ( user is None ) : raise HTTPError ( http . UNAUTHORIZED ) if ( not node . has_permission ( user , permission ) ) : raise HTTPError ( http . FORBIDDEN ) return func ( * args , ** kwargs ) return wrapped return wrapper
decorator factory for checking permissions .