def copy_current_request_context(f):
 top = _request_ctx_stack.top
 if (top is None):
  raise RuntimeError('This decorator can only be used at local scopes when a request context is on the stack.  For instance within view functions.')
 reqctx = top.copy()
 def wrapper(*args, **kwargs):
  with reqctx:
   return f(*args, **kwargs)
 return update_wrapper(wrapper, f)

def copy_current_request_context ( f ) : top = _request_ctx_stack . top if ( top is None ) : raise RuntimeError ( 'This decorator can only be used at local scopes when a request context is on the stack.  For instance within view functions.' ) reqctx = top . copy ( ) def wrapper ( * args , ** kwargs ) : with reqctx : return f ( * args , ** kwargs ) return update_wrapper ( wrapper , f )
a helper function that decorates a function to retain the current request context .