def register_on(self, app):
"""This registers the `BlueprintNavigation` for the Flask app.
This uses a `list` in the flask config object to register the
navigation. The key for the `list` is "blueprint_navigation".
The template iterates over this list and renders the navigation
elements. The order the elements are registered is the order the
elements will be shown.
:param app: A `flask.Flask` application instance.
"""
if self.blueprint.name not in app.blueprints:
raise Exception("Blueprint %s is not registred in Flask app" %
self.blueprint.name)
else:
assert app.blueprints[self.blueprint.name] is self.blueprint, \
"Blueprint resistred as %s in Flask app is not the one you " \
"register navigation for!"
if "blueprint_navigation" not in app.config:
app.config["blueprint_navigation"] = list()
app.config["blueprint_navigation"].append(self)
评论列表
文章目录