fix: get back _blueprint_order, important for template searching

This commit is contained in:
laggardkernel 2021-05-28 18:10:53 +08:00
parent a960236117
commit eda118964c
3 changed files with 8 additions and 1 deletions

View file

@ -8,6 +8,10 @@ Unreleased
- Fix type annotation for ``teardown_request``. :issue:`4093`
- Fix type annotation for ``before_request`` and ``before_app_request``
decorators. :issue:`4104`
- Re-add the ``Flask._blueprint_order`` list. Take blueprint registration
order into consideration when searching for templates in
``DispatchingJinjaLoader._iter_loaders()``,
``DispatchingJinjaLoader.list_templates()``.
Version 2.0.1

View file

@ -463,6 +463,7 @@ class Flask(Scaffold):
#:
#: .. versionadded:: 0.7
self.blueprints: t.Dict[str, "Blueprint"] = {}
self._blueprint_order: t.List[Blueprint] = []
#: a place where extensions can store application specific state. For
#: example this is where an extension could store database engines and
@ -1035,7 +1036,7 @@ class Flask(Scaffold):
.. versionadded:: 0.11
"""
return self.blueprints.values()
return iter(self._blueprint_order)
@setupmethod
def add_url_rule(

View file

@ -319,6 +319,8 @@ class Blueprint(Scaffold):
)
app.blueprints[name] = self
if self not in app._blueprint_order:
app._blueprint_order.append(self)
self._got_registered_once = True
state = self.make_setup_state(app, options, first_registration)