python - Flask - A blueprint's name collision occurred -


i met issue. console said blueprint's name collision occurred think it's not belong flask-bootsrap problem. believe have config or unknown let me met issue.

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: blueprint's name collision occurred between <flask.blueprints.blueprint object @ 0x034ea230> , <flask.blueprints.blueprint object @ 0x0349 7770>.  both share same name "bootstrap".  blueprints created on fly need unique names. 

this code. don't know happen.

#!/usr/bin/env python # -*- coding: utf-8 -*- #  @first_date    20160129 #  @date          20160129 #  @version       0.0 """init flask app """ flask import flask  flask.ext.bootstrap import bootstrap flask.ext.sqlalchemy import sqlalchemy flask.ext.marshmallow import marshmallow flask.ext.login import loginmanager  import configs   # initializing process: package main flask app app = flask(__name__) app.config.from_object(configs.configs['default'])   # initializing process: extesion list 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 flask app extensions'''     # extension list: wrap extensions     extensions = (         bootstrap,         db,         ma,  # warning: flask-sqlalchemy must initialized before flask-marshmallow.         login_manager,     )     # initializing process: start initial each extension     extension in extensions:         extension.init_app(app=app)    def init_blueprints(app):     '''initializing flask app blueprints'''     # blueprint source: import blueprints , note these sources     .views import users      .web import web_bp      # blueprint list: wrap blueprints     buleprints = (         dict(blueprint=users.users_bp, url_prefix='/users'),          dict(blueprint=web_bp, url_prefix=''),     )      # initializing process: start initial each blueprint     blueprint in buleprints:         app.register_blueprint(**blueprint)   def init_error_handlers(app):     '''import error handler function'''     .error_handlers.built_in_exception_handlers import *     .error_handlers.status_code_handlers import *     .error_handlers.sqlachelmy_handlers import *   def create_app():     '''it's factory.'''     # initializing process: initializing main flask app extensions     init_extensions(app)      # initializing process: initializing main flask app blueprints     init_blueprints(app)      # initializing process: import error handlers     init_error_handlers(app)      return app 

or may tell me how lookup blueprint object in app , let me trace bug. thanks.

it looks app registering bootstrap blueprint twice. there line in bootstrap's source code register in init_app()

try either removing here:

    ...     bootstrap,     db,     ma,  # warning: flask-sqlalchemy must initialized before flask-marshmallow.     login_manager, 

or tuple:

# blueprint list: wrap blueprints     buleprints = (         dict(blueprint=users.users_bp, url_prefix='/users'),          dict(blueprint=web_bp, url_prefix=''),     ) 

Comments

  1. @admin
    Can you explain about python little bit more and share some other programming languages
    Regards,
    Deepika Verma

    ReplyDelete

Post a Comment

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -