forked from orbit-oss/flask
Support async template context processors
This is useful as there is contextual information that could be loaded via IO e.g. information from a database. This also matches Quart and hence makes the shared signature easier to manage.
This commit is contained in:
parent
72c85e80c8
commit
3f6b243cec
2 changed files with 5 additions and 2 deletions
|
|
@ -478,7 +478,7 @@ class Flask(App):
|
||||||
for name in names:
|
for name in names:
|
||||||
if name in self.template_context_processors:
|
if name in self.template_context_processors:
|
||||||
for func in self.template_context_processors[name]:
|
for func in self.template_context_processors[name]:
|
||||||
context.update(func())
|
context.update(self.ensure_sync(func)())
|
||||||
|
|
||||||
context.update(orig_ctx)
|
context.update(orig_ctx)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,10 @@ TeardownCallable = t.Union[
|
||||||
t.Callable[[t.Optional[BaseException]], None],
|
t.Callable[[t.Optional[BaseException]], None],
|
||||||
t.Callable[[t.Optional[BaseException]], t.Awaitable[None]],
|
t.Callable[[t.Optional[BaseException]], t.Awaitable[None]],
|
||||||
]
|
]
|
||||||
TemplateContextProcessorCallable = t.Callable[[], t.Dict[str, t.Any]]
|
TemplateContextProcessorCallable = t.Union[
|
||||||
|
t.Callable[[], t.Dict[str, t.Any]],
|
||||||
|
t.Callable[[], t.Awaitable[t.Dict[str, t.Any]]],
|
||||||
|
]
|
||||||
TemplateFilterCallable = t.Callable[..., t.Any]
|
TemplateFilterCallable = t.Callable[..., t.Any]
|
||||||
TemplateGlobalCallable = t.Callable[..., t.Any]
|
TemplateGlobalCallable = t.Callable[..., t.Any]
|
||||||
TemplateTestCallable = t.Callable[..., bool]
|
TemplateTestCallable = t.Callable[..., bool]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue