sbook/flask-mongoengine — Issue #10: Blueprints seem unsupported
Author: maxcountryman
Created: 2011-10-11 14:12:05+00:00
State: open

Hi,

I'm unsure where the problem truly lies, but as best as I can tell at the moment, this is something that seems to work with Flask-SQLAlchemy and not with Flask-MonogEngine. So I thought I'd open up an issue thread here and see if there's any insight that can be provided.

Essentially what is happening is I have an application with a couple of Blueprint objects that need to share the db object. They expect to import this from the project, e.g. `from project import db`. However this is resulting in an ImportError.

The app object is created in the project's `__init__.py` the blueprints are registered and then the db object is created.

```app = Flask(__name__)

from project.views.admin import admin
from project.views.frontend import frontend
app.register_blueprint(admin)
app.register_blueprint(frontend)

db = MongoEngine(app)```

The blueprints are making use of their own set of document models. This is where the import error occurs, seemingly because the db object hasn't been created yet. It seems odd though that such a configuration would work with SQLAlchemy.

It's quite possible I'm doing something blatantly wrong here. However this model does seem to work with other ORMs, so perhaps there's a trick to getting it to work with MongoEngine?