pallets / flask

The Python micro framework for building web applications.
https://flask.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
68.02k stars 16.21k forks source link

Adding Couchdb views from blueprint #2349

Closed pseudoPixels closed 7 years ago

pseudoPixels commented 7 years ago

Adding Couchdb views from the blueprints are showing error... Tried with accessing the main app as 'current_app' but showing error 'RuntimeError: Working outside of application context.' My Code from blueprint for adding/syncing couchdb views are as following:

from flask import current_app as app
manager = CouchDBManager()

with app.app_context():
    manager.setup(app.app_context())
    manager.add_viewdef(my_couchdb_view_from_blueprint)
    manager.sync(app.app_context())

The error message is as following:

RuntimeError: Working outside of application context. This typically means that you attempted to use functionality that needed to interface with the current application object in a way. To solve this set up an application context with app.app_context().

ThiefMaster commented 7 years ago

Please use IRC or Stack Overflow for support questions.