Home / File/ ctx.py — flask Source File

ctx.py — flask Source File

Architecture documentation for ctx.py, a python file in the flask codebase. 18 imports, 4 dependents.

File python ApplicationCore Scaffolding 18 imports 4 dependents 6 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  49f8280b_d7dc_110c_b848_8e7e56bfb19b["ctx.py"]
  949a3336_caad_34e4_9d3f_a6e1653188ba["949a3336:caad:34e4:9d3f:a6e1653188ba"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 949a3336_caad_34e4_9d3f_a6e1653188ba
  9cff5a62_7dbb_7b80_cf3c_128a7a2fda28["globals.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28
  f7678070_c632_9fab_268f_e2310036493f["signals.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> f7678070_c632_9fab_268f_e2310036493f
  9612cfdd_2178_92c0_2ed7_16ebb0c72901["app.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 9612cfdd_2178_92c0_2ed7_16ebb0c72901
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5
  f793a407_79ea_667a_f29e_29bbf57c781f["sessions.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> f793a407_79ea_667a_f29e_29bbf57c781f
  22ae6a8e_9381_0dda_c9eb_5c5c7c0d67b1["SessionMixin"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 22ae6a8e_9381_0dda_c9eb_5c5c7c0d67b1
  fb9bd0c5_9d0a_c235_58cf_8d691dde64fb["wrappers.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> fb9bd0c5_9d0a_c235_58cf_8d691dde64fb
  eae007fa_ef39_ed97_113d_df4ad5001c0e["Request"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> eae007fa_ef39_ed97_113d_df4ad5001c0e
  e85d63df_8800_dd10_f85e_a10ee3e12a7e["contextvars"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> e85d63df_8800_dd10_f85e_a10ee3e12a7e
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  3eebf5bc_1ef0_6524_701b_beec8ec8524a["functools"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 3eebf5bc_1ef0_6524_701b_beec8ec8524a
  27bc050a_0167_5d02_546e_7c5efffc737b["types"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 27bc050a_0167_5d02_546e_7c5efffc737b
  9b468bc7_cc0b_fef2_ed71_07b4f027fb55["werkzeug.exceptions"]
  49f8280b_d7dc_110c_b848_8e7e56bfb19b --> 9b468bc7_cc0b_fef2_ed71_07b4f027fb55
  style 49f8280b_d7dc_110c_b848_8e7e56bfb19b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import contextvars
import typing as t
from functools import update_wrapper
from types import TracebackType

from werkzeug.exceptions import HTTPException
from werkzeug.routing import MapAdapter

from . import typing as ft
from .globals import _cv_app
from .signals import appcontext_popped
from .signals import appcontext_pushed

if t.TYPE_CHECKING:
    import typing_extensions as te
    from _typeshed.wsgi import WSGIEnvironment

    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request


# a singleton sentinel value for parameter defaults
_sentinel = object()


class _AppCtxGlobals:
    """A plain object. Used as a namespace for storing data during an
    application context.

    Creating an app context automatically creates this object, which is
    made available as the :data:`.g` proxy.

    .. describe:: 'key' in g

        Check whether an attribute is present.

        .. versionadded:: 0.10

    .. describe:: iter(g)

        Return an iterator over the attribute names.

        .. versionadded:: 0.10
    """

    # Define attr methods to let mypy know this is a namespace object
    # that has arbitrary attributes.

    def __getattr__(self, name: str) -> t.Any:
        try:
            return self.__dict__[name]
        except KeyError:
            raise AttributeError(name) from None

    def __setattr__(self, name: str, value: t.Any) -> None:
        self.__dict__[name] = value

// ... (457 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does ctx.py do?
ctx.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 ctx.py?
ctx.py defines 6 function(s): __getattr__, after_this_request, copy_current_request_context, has_app_context, has_request_context, typing_extensions.
What does ctx.py depend on?
ctx.py imports 18 module(s): 949a3336:caad:34e4:9d3f:a6e1653188ba, Flask, Request, SessionMixin, _typeshed.wsgi, app.py, contextvars, functools, and 10 more.
What files import ctx.py?
ctx.py is imported by 4 file(s): __init__.py, app.py, globals.py, templating.py.
Where is ctx.py in the architecture?
ctx.py is located at src/flask/ctx.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