| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | # -*- coding: utf-8 -*-"""    flask.globals    ~~~~~~~~~~~~~    Defines all the global objects that are proxies to the current    active context.    :copyright: 2010 Pallets    :license: BSD-3-Clause"""from functools import partialfrom werkzeug.local import LocalProxyfrom werkzeug.local import LocalStack_request_ctx_err_msg = """\Working outside of request context.This typically means that you attempted to use functionality that neededan active HTTP request.  Consult the documentation on testing forinformation about how to avoid this problem.\"""_app_ctx_err_msg = """\Working outside of application context.This typically means that you attempted to use functionality that neededto interface with the current application object in some way. To solvethis, set up an application context with app.app_context().  See thedocumentation for more information.\"""def _lookup_req_object(name):    top = _request_ctx_stack.top    if top is None:        raise RuntimeError(_request_ctx_err_msg)    return getattr(top, name)def _lookup_app_object(name):    top = _app_ctx_stack.top    if top is None:        raise RuntimeError(_app_ctx_err_msg)    return getattr(top, name)def _find_app():    top = _app_ctx_stack.top    if top is None:        raise RuntimeError(_app_ctx_err_msg)    return top.app# context locals_request_ctx_stack = LocalStack()_app_ctx_stack = LocalStack()current_app = LocalProxy(_find_app)request = LocalProxy(partial(_lookup_req_object, "request"))session = LocalProxy(partial(_lookup_req_object, "session"))g = LocalProxy(partial(_lookup_app_object, "g"))
 |