3

問題が発生しました。コンソールには、A blueprint's name collision occurred と表示されましたが、flask-bootsrap の問題ではないと思います。問題を解決できる構成または未知の何かがあると思います。

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    app = create_app()
  File "D:\TONY\GitHub\private-home-flask-cuisine\db-example\app\__init__.py", line 79, in create_app
    init_extensions(app)
  File "D:\TONY\GitHub\private-home-flask-cuisine\db-example\app\__init__.py", line 46, in init_extensions
    extension.init_app(app=app)
  File "D:\TONY\GitHub\private-home-flask-cuisine\db-example\env\lib\site-packages\flask_bootstrap\__init__.py", line 137, in init_app
    app.register_blueprint(blueprint)
  File "D:\TONY\GitHub\private-home-flask-cuisine\db-example\env\lib\site-packages\flask\app.py", line 62, in wrapper_func
    return f(self, *args, **kwargs)
  File "D:\TONY\GitHub\private-home-flask-cuisine\db-example\env\lib\site-packages\flask\app.py", line 885, in register_blueprint
    (blueprint, self.blueprints[blueprint.name], blueprint.name)
AssertionError: A blueprint's name collision occurred between <flask.blueprints.Blueprint object at 0x034EA230> and <flask.blueprints.Blueprint object at 0x0349
7770>.  Both share the same name "bootstrap".  Blueprints that are created on the fly need unique names.

これは私のコードです。何が起こるかわかりません。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#  @first_date    20160129
#  @date          20160129
#  @version       0.0
"""Init flask app
"""
from flask import Flask

from flask.ext.bootstrap import Bootstrap
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.marshmallow import Marshmallow
from flask.ext.login import LoginManager

import configs


# Initializing process: This package is main flask app
app = Flask(__name__)
app.config.from_object(configs.CONFIGS['default'])


# Initializing process: This extesion list is created extension object
bootstrap = Bootstrap()
db = SQLAlchemy()
ma = Marshmallow()


login_manager = LoginManager()
login_manager.session_protection = "strong"
login_manager.login_view = 'users.login'


def init_extensions(app):
    '''Initializing the flask app with extensions'''
    # Extension List: Wrap up the all extensions
    extensions = (
        bootstrap,
        db,
        ma,  # Warning: Flask-SQLAlchemy must be initialized before Flask-Marshmallow.
        login_manager,
    )
    # Initializing process: Start to initial each extension
    for extension in extensions:
        extension.init_app(app=app)



def init_blueprints(app):
    '''Initializing the flask app with blueprints'''
    # Blueprint source: Import the blueprints and note these sources
    from .views import users

    from .web import web_bp

    # Blueprint List: Wrap up the all blueprints
    buleprints = (
        dict(blueprint=users.users_bp, url_prefix='/users'),

        dict(blueprint=web_bp, url_prefix=''),
    )

    # Initializing process: Start to initial each blueprint
    for blueprint in buleprints:
        app.register_blueprint(**blueprint)


def init_error_handlers(app):
    '''import error handler function'''
    from .error_handlers.built_in_exception_handlers import *
    from .error_handlers.status_code_handlers import *
    from .error_handlers.sqlachelmy_handlers import *


def create_app():
    '''It's a factory.'''
    # Initializing process: Initializing the main flask app with extensions
    init_extensions(app)

    # Initializing process: Initializing the main flask app with blueprints
    init_blueprints(app)

    # Initializing process: import error handlers
    init_error_handlers(app)

    return app

または、誰かがアプリでブループリント オブジェクトを検索する方法を教えてくれ、バグを追跡できるようにするかもしれません。ありがとう。

4

1 に答える 1