We do not encourage people to create more than one database connection and to connect to databases in arbitrary extensions. The obvious exception are extensions whose sole purpose is to connect to databases. Dependency resolving is done by the developer. Eg:
app = Flask(__name__)
db = SQLAlchemy(app)
something = SomethingElse(app, db)
The problem comes with blueprints. If SomethingElse wants to define models it has to do that at a local scope where it has the reference to the db. Assuming it provides blueprints, how does the blueprint's views and other code get to the models? The sad truth is that if you make up blueprints on the fly the views in that blueprint don't know how to reference it.
It depends from the use case.
I have following assumptions:
1. Application might want to access blueprint models
2. There can be more than one instance of the blueprint, so there can be multiple instances of the same model mapped to different or same database table(s) (using prefixed table name, etc)
3. Blueprints don't know how they're going to be used in the application - all parameters are passed in object creation time
4. Which brings to the point - blueprints should always dynamicly create their models based on the input parameters to the constructor
For #1, snippet can look like:
I came across this issue with my bugLink project (http://buglink.readthedocs.org/), where the basic app knows about the relationship changeset <-> issue, and extensions to the app should provide release <-> build <-> changeset ( <-> issue).
My understanding of this is that Blueprint are intended to extend the views. If you need to extend the model, you need to define something like a YellowPrint. As the model is highly coupled with the controller, YellowPrint could also have some mechanism in place to extend your controller. But there is no point in extending the controller if you don't make use of the extension provided. Here we come back to the views. Which brings us to the GreenPrint if you need to extend the views and the model.
I don't know if this is exactly the situation you are describing, but I have something that looks like this in Flask-Restless. Check out http://readthedocs.org/docs/flask-restless/en/latest/quickstart.html