def with_appcontext(f):
 @click.pass_context
 def decorator(__ctx, *args, **kwargs):
  with __ctx.ensure_object(ScriptInfo).load_app().app_context():
   return __ctx.invoke(f, *args, **kwargs)
 return update_wrapper(decorator, f)

def with_appcontext ( f ) : @ click . pass_context def decorator ( __ctx , * args , ** kwargs ) : with __ctx . ensure_object ( ScriptInfo ) . load_app ( ) . app_context ( ) : return __ctx . invoke ( f , * args , ** kwargs ) return update_wrapper ( decorator , f )
wraps a callback so that its guaranteed to be executed with the scripts application context .