globals.py — flask Source File
Architecture documentation for globals.py, a python file in the flask codebase. 13 imports, 11 dependents.
Entity Profile
Dependency Diagram
graph LR 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28["globals.py"] 9612cfdd_2178_92c0_2ed7_16ebb0c72901["app.py"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 9612cfdd_2178_92c0_2ed7_16ebb0c72901 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 49f8280b_d7dc_110c_b848_8e7e56bfb19b["ctx.py"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 49f8280b_d7dc_110c_b848_8e7e56bfb19b 27fd902b_d034_0c03_9e1b_dd8edc261a75["_AppCtxGlobals"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 27fd902b_d034_0c03_9e1b_dd8edc261a75 86817dcd_97b5_9a9f_aee8_5fa78b4cecc9["AppContext"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 86817dcd_97b5_9a9f_aee8_5fa78b4cecc9 f793a407_79ea_667a_f29e_29bbf57c781f["sessions.py"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> f793a407_79ea_667a_f29e_29bbf57c781f 22ae6a8e_9381_0dda_c9eb_5c5c7c0d67b1["SessionMixin"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 22ae6a8e_9381_0dda_c9eb_5c5c7c0d67b1 fb9bd0c5_9d0a_c235_58cf_8d691dde64fb["wrappers.py"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> fb9bd0c5_9d0a_c235_58cf_8d691dde64fb eae007fa_ef39_ed97_113d_df4ad5001c0e["Request"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> eae007fa_ef39_ed97_113d_df4ad5001c0e d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac e85d63df_8800_dd10_f85e_a10ee3e12a7e["contextvars"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> e85d63df_8800_dd10_f85e_a10ee3e12a7e 5301647b_918a_536b_6b91_a88158392196["werkzeug.local"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 5301647b_918a_536b_6b91_a88158392196 7dd1dda8_d340_e81e_65f0_3423e3d7e968["warnings"] 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 --> 7dd1dda8_d340_e81e_65f0_3423e3d7e968 e1ae29a1_73d3_d5e9_3fd5_548f4ac50138["__init__.py"] e1ae29a1_73d3_d5e9_3fd5_548f4ac50138 --> 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 style 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import typing as t
from contextvars import ContextVar
from werkzeug.local import LocalProxy
if t.TYPE_CHECKING: # pragma: no cover
from .app import Flask
from .ctx import _AppCtxGlobals
from .ctx import AppContext
from .sessions import SessionMixin
from .wrappers import Request
T = t.TypeVar("T", covariant=True)
class ProxyMixin(t.Protocol[T]):
def _get_current_object(self) -> T: ...
# These subclasses inform type checkers that the proxy objects look like the
# proxied type along with the _get_current_object method.
class FlaskProxy(ProxyMixin[Flask], Flask): ...
class AppContextProxy(ProxyMixin[AppContext], AppContext): ...
class _AppCtxGlobalsProxy(ProxyMixin[_AppCtxGlobals], _AppCtxGlobals): ...
class RequestProxy(ProxyMixin[Request], Request): ...
class SessionMixinProxy(ProxyMixin[SessionMixin], SessionMixin): ...
_no_app_msg = """\
Working outside of application context.
Attempted to use functionality that expected a current application to be set. To
solve this, set up an app context using 'with app.app_context()'. See the
documentation on app context for more information.\
"""
_cv_app: ContextVar[AppContext] = ContextVar("flask.app_ctx")
app_ctx: AppContextProxy = LocalProxy( # type: ignore[assignment]
_cv_app, unbound_message=_no_app_msg
)
current_app: FlaskProxy = LocalProxy( # type: ignore[assignment]
_cv_app, "app", unbound_message=_no_app_msg
)
g: _AppCtxGlobalsProxy = LocalProxy( # type: ignore[assignment]
_cv_app, "g", unbound_message=_no_app_msg
)
_no_req_msg = """\
Working outside of request context.
Attempted to use functionality that expected an active HTTP request. See the
documentation on request context for more information.\
"""
request: RequestProxy = LocalProxy( # type: ignore[assignment]
_cv_app, "request", unbound_message=_no_req_msg
)
session: SessionMixinProxy = LocalProxy( # type: ignore[assignment]
_cv_app, "session", unbound_message=_no_req_msg
)
def __getattr__(name: str) -> t.Any:
import warnings
if name == "request_ctx":
warnings.warn(
"'request_ctx' has merged with 'app_ctx', and will be removed"
" in Flask 4.0. Use 'app_ctx' instead.",
DeprecationWarning,
stacklevel=2,
)
return app_ctx
raise AttributeError(name)
Domain
Subdomains
Functions
Dependencies
- AppContext
- Flask
- Request
- SessionMixin
- _AppCtxGlobals
- app.py
- contextvars
- ctx.py
- sessions.py
- typing.py
- warnings
- werkzeug.local
- wrappers.py
Imported By
Source
Frequently Asked Questions
What does globals.py do?
globals.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, Scaffolding subdomain.
What functions are defined in globals.py?
globals.py defines 2 function(s): __getattr__, app.
What does globals.py depend on?
globals.py imports 13 module(s): AppContext, Flask, Request, SessionMixin, _AppCtxGlobals, app.py, contextvars, ctx.py, and 5 more.
What files import globals.py?
globals.py is imported by 11 file(s): __init__.py, app.py, blueprints.py, cli.py, ctx.py, debughelpers.py, helpers.py, logging.py, and 3 more.
Where is globals.py in the architecture?
globals.py is located at src/flask/globals.py (domain: ApplicationCore, subdomain: Scaffolding, directory: src/flask).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free