navigation.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:pycroft 作者: agdsn 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号