update_template_context() — flask Function Reference
Architecture documentation for the update_template_context() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 8c4a599b_81bd_7179_af9c_5ae61d56dc9d["update_template_context()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 8c4a599b_81bd_7179_af9c_5ae61d56dc9d -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 a89c0022_4807_bf16_9be1_6a66f3c78c9f["ensure_sync()"] 8c4a599b_81bd_7179_af9c_5ae61d56dc9d -->|calls| a89c0022_4807_bf16_9be1_6a66f3c78c9f b9619729_0242_23b5_d6f7_5f78607ae976["copy()"] 8c4a599b_81bd_7179_af9c_5ae61d56dc9d -->|calls| b9619729_0242_23b5_d6f7_5f78607ae976 style 8c4a599b_81bd_7179_af9c_5ae61d56dc9d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 589–617
def update_template_context(
self, ctx: AppContext, context: dict[str, t.Any]
) -> None:
"""Update the template context with some commonly used variables.
This injects request, session, config and g into the template
context as well as everything template context processors want
to inject. Note that the as of Flask 0.6, the original values
in the context will not be overridden if a context processor
decides to return a value with the same key.
:param context: the context as a dictionary that is updated in place
to add extra variables.
"""
names: t.Iterable[str | None] = (None,)
# A template may be rendered outside a request context.
if ctx.has_request:
names = chain(names, reversed(ctx.request.blueprints))
# The values passed to render_template take precedence. Keep a
# copy to re-apply after all context functions.
orig_ctx = context.copy()
for name in names:
if name in self.template_context_processors:
for func in self.template_context_processors[name]:
context.update(self.ensure_sync(func)())
context.update(orig_ctx)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does update_template_context() do?
update_template_context() is a function in the flask codebase, defined in src/flask/app.py.
Where is update_template_context() defined?
update_template_context() is defined in src/flask/app.py at line 589.
What does update_template_context() call?
update_template_context() calls 2 function(s): copy, ensure_sync.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free