Record blueprint registration order.

This commit is contained in:
Armin Ronacher 2014-09-03 20:12:06 +02:00
parent 750ab16364
commit c09a4317e4
3 changed files with 14 additions and 3 deletions

View file

@ -472,6 +472,7 @@ class Flask(_PackageBoundObject):
#:
#: .. versionadded:: 0.7
self.blueprints = {}
self._blueprint_order = []
#: a place where extensions can store application specific state. For
#: example this is where an extension could store database engines and
@ -903,9 +904,17 @@ class Flask(_PackageBoundObject):
(blueprint, self.blueprints[blueprint.name], blueprint.name)
else:
self.blueprints[blueprint.name] = blueprint
self._blueprint_order.append(blueprint)
first_registration = True
blueprint.register(self, options, first_registration)
def iter_blueprints(self):
"""Iterates over all blueprints by the order they were registered.
.. versionadded:: 1.0
"""
return iter(self._blueprint_order)
@setupmethod
def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
"""Connects a URL rule. Works exactly like the :meth:`route`