I want to create a blueprint; not an issue with the current blueprint I have. I can do this.
But, say I wanted to use a flask extension in my application (for my case I want to integrate flask-Cache)?
Everything I’ve done so far has errored:
-
cache = Cache(my_blueprint)
-
importing Cache and various parts of Cache in varying guises
so something like flask-cache is simple enough to wrap around my app:
from flask.ext.cache import Cache
cache = Cache(app)
but using this in a blueprint or using with a blueprint I don’t quite understand how right now.
EDIT: the less obvious solution was to crib from the extension and build my own library to import into the blueprint, but it is more work and I’m not quite done yet. extensions / blueprints don’t seem to be compatible from my level of understanding right now.
In order to avoid circular imports you will want to create your cache instance separate from your application instance (you may want to consider switching to the app factory module if you are building something more complex).
cache.py
foo.py
app.py