def make_pass_decorator(object_type, ensure=False):
 def decorator(f):
  def new_func(*args, **kwargs):
   ctx = get_current_context()
   if ensure:
    obj = ctx.ensure_object(object_type)
   else:
    obj = ctx.find_object(object_type)
   if (obj is None):
    raise RuntimeError(('Managed to invoke callback without a context object of type %r existing' % object_type.__name__))
   return ctx.invoke(f, obj, *args[1:], **kwargs)
  return update_wrapper(new_func, f)
 return decorator

def make_pass_decorator ( object_type , ensure = False ) : def decorator ( f ) : def new_func ( * args , ** kwargs ) : ctx = get_current_context ( ) if ensure : obj = ctx . ensure_object ( object_type ) else : obj = ctx . find_object ( object_type ) if ( obj is None ) : raise RuntimeError ( ( 'Managed to invoke callback without a context object of type %r existing' % object_type . __name__ ) ) return ctx . invoke ( f , obj , * args [ 1 : ] , ** kwargs ) return update_wrapper ( new_func , f ) return decorator
given an object type this creates a decorator that will work similar to :func:pass_obj but instead of passing the object of the current context .