def request_user_has_resource_api_permission(permission_type):
 def decorate(func):
  function_name = func.__name__
  if (function_name not in ['post']):
   raise Exception('This decorator should only be used to wrap post methods')
  @wraps(func)
  def func_wrapper(*args, **kwargs):
   resource_api = args[1]
   utils.assert_request_user_has_resource_api_permission(request=pecan.request, resource_api=resource_api, permission_type=permission_type)
   return func(*args, **kwargs)
  return func_wrapper
 return decorate

def request_user_has_resource_api_permission ( permission_type ) : def decorate ( func ) : function_name = func . __name__ if ( function_name not in [ 'post' ] ) : raise Exception ( 'This decorator should only be used to wrap post methods' ) @ wraps ( func ) def func_wrapper ( * args , ** kwargs ) : resource_api = args [ 1 ] utils . assert_request_user_has_resource_api_permission ( request = pecan . request , resource_api = resource_api , permission_type = permission_type ) return func ( * args , ** kwargs ) return func_wrapper return decorate
a decorator meant to wrap post pecan rest controller methods this decorator assumes the first argument passed to the decorated function is a resource api object .