【发布时间】:2021-08-12 01:30:00
【问题描述】:
我使用“flask fab create-addon”创建了一个烧瓶插件。
我想更改模板 appbuilder/general/security/login_oauth.html 所以我有:
templates
appbuilder
general
security
login_oauth.html
但是当我加载主机应用程序时,我的 login_oauth.html 版本没有加载。我尝试使用以下代码在this post 中注册蓝图:
from flask import Blueprint
bp = Blueprint('fab_addon_fslogin', __name__, template_folder='templates')
class MyAddOnManager(BaseManager):
def __init__(self, appbuilder):
"""
Use the constructor to setup any config keys specific for your app.
"""
super(MyAddOnManager, self).__init__(appbuilder)
self.appbuilder.get_app.config.setdefault("MYADDON_KEY", "SOME VALUE")
self.appbuilder.register_blueprint(bp)
def register_views(self):
"""
This method is called by AppBuilder when initializing, use it to add you views
"""
pass
def pre_process(self):
pass
def post_process(self):
pass
但是 register_blueprint(bp) 返回:
File "/home/cquiros/data/projects2017/personal/software/superset/addons/fab_addon_fslogin/fab_addon_fslogin/manager.py", line 24, in __init__
self.appbuilder.register_blueprint(bp)
File "/home/cquiros/data/projects2017/personal/software/superset/env_superset/lib/python3.8/site-packages/Flask_AppBuilder-3.3.0-py3.8.egg/flask_appbuilder/base.py", line 643, in register_blueprint
baseview.create_blueprint(
AttributeError: 'Blueprint' object has no attribute 'create_blueprint'
没有太多关于如何做到这一点的信息。任何线索表示赞赏
【问题讨论】:
标签: python flask flask-appbuilder