fix DispatchingJinjaLoader to not use internal methods of parent class
This commit is contained in:
parent
9e31c8c673
commit
29d1a3226a
@ -21,11 +21,24 @@ class DispatchingJinjaLoader(quart.templating.DispatchingJinjaLoader):
|
||||
def __init__(self, app: MyQuartApp) -> None:
|
||||
super().__init__(app)
|
||||
|
||||
def _loaders(self) -> typing.Generator[jinja2.BaseLoader, None, None]:
|
||||
def get_source(
|
||||
self,
|
||||
environment: typing.Any,
|
||||
template: str,
|
||||
) -> tuple[str, str | None, typing.Callable | None]:
|
||||
if self.app.custom_loader:
|
||||
yield self.app.custom_loader
|
||||
for loader in super()._loaders():
|
||||
yield loader
|
||||
try:
|
||||
return self.app.custom_loader.get_source(environment, template)
|
||||
except jinja2.TemplateNotFound:
|
||||
pass
|
||||
return super().get_source(environment, template)
|
||||
|
||||
def list_templates(self) -> list[str]:
|
||||
result = set()
|
||||
if self.app.custom_loader:
|
||||
result.update(self.app.custom_loader.list_templates())
|
||||
result.update(super().list_templates())
|
||||
return list(result)
|
||||
|
||||
|
||||
class MyQuartApp(quart_trio.QuartTrio):
|
||||
|
Loading…
Reference in New Issue
Block a user