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 wi
(self, context: dict[str, t.Any])
| 504 | raise FormDataRoutingRedirect(request) |
| 505 | |
| 506 | def update_template_context(self, context: dict[str, t.Any]) -> None: |
| 507 | """Update the template context with some commonly used variables. |
| 508 | This injects request, session, config and g into the template |
| 509 | context as well as everything template context processors want |
| 510 | to inject. Note that the as of Flask 0.6, the original values |
| 511 | in the context will not be overridden if a context processor |
| 512 | decides to return a value with the same key. |
| 513 | |
| 514 | :param context: the context as a dictionary that is updated in place |
| 515 | to add extra variables. |
| 516 | """ |
| 517 | names: t.Iterable[str | None] = (None,) |
| 518 | |
| 519 | # A template may be rendered outside a request context. |
| 520 | if request: |
| 521 | names = chain(names, reversed(request.blueprints)) |
| 522 | |
| 523 | # The values passed to render_template take precedence. Keep a |
| 524 | # copy to re-apply after all context functions. |
| 525 | orig_ctx = context.copy() |
| 526 | |
| 527 | for name in names: |
| 528 | if name in self.template_context_processors: |
| 529 | for func in self.template_context_processors[name]: |
| 530 | context.update(self.ensure_sync(func)()) |
| 531 | |
| 532 | context.update(orig_ctx) |
| 533 | |
| 534 | def make_shell_context(self) -> dict[str, t.Any]: |
| 535 | """Returns the shell context for an interactive shell for this |
no test coverage detected