def request_user_has_resource_db_permission(permission_type):
 valid_method_names = ['get_one', 'get', 'post', 'put', 'delete']
 def decorate(func):
  function_name = func.__name__
  if (function_name not in valid_method_names):
   raise Exception(('This decorator should only be used to wrap %s methods' % ', '.join(valid_method_names)))
  @wraps(func)
  def func_wrapper(*args, **kwargs):
   controller_instance = args[0]
   resource_id = args[1]
   get_one_db_method = controller_instance.get_one_db_method
   resource_db = get_one_db_method(resource_id)
   assert (resource_db is not None)
   utils.assert_request_user_has_resource_db_permission(request=pecan.request, resource_db=resource_db, permission_type=permission_type)
   return func(*args, **kwargs)
  return func_wrapper
 return decorate

def request_user_has_resource_db_permission ( permission_type ) : valid_method_names = [ 'get_one' , 'get' , 'post' , 'put' , 'delete' ] def decorate ( func ) : function_name = func . __name__ if ( function_name not in valid_method_names ) : raise Exception ( ( 'This decorator should only be used to wrap %s methods' % ', ' . join ( valid_method_names ) ) ) @ wraps ( func ) def func_wrapper ( * args , ** kwargs ) : controller_instance = args [ 0 ] resource_id = args [ 1 ] get_one_db_method = controller_instance . get_one_db_method resource_db = get_one_db_method ( resource_id ) assert ( resource_db is not None ) utils . assert_request_user_has_resource_db_permission ( request = pecan . request , resource_db = resource_db , permission_type = permission_type ) return func ( * args , ** kwargs ) return func_wrapper return decorate
a decorator meant to wrap post .