You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building a blueprint (or a project), it's possible to hook functions into the site setup process using blueprint.record. which gets called when a Flask blueprint gets attached to an app. This is fine for getting at the site's underlying Flask app, but there's no reference to the site itself, or the project config.
Here's my use case: I'm building a Tarbell blueprint where I want to use Flask-Assets and look for an assets.yml file in my project directory. I'd like to configure the extension (flask.ext.assets.Environment(app)) in blueprint.record, and then further configure it based on tarbell_config.py or assets.yml.
Now, I could assume that blueprint.py will always be in project/_blueprint and climb up a directory, but that seems like bad practice.
A couple options I can see:
I think it would be possible to pass a site argument in app.register_blueprinthere. As far as I can tell, keyword arguments get passed along to blueprint.record, so a reference to the current site could get passed around.
We could add a new hook (or signal, depending on Proposal: Replace hooks with signals #413) for when a Tarbell blueprint gets loaded, and/or at the end of `TarbellSite.init.
Those aren't mutually exclusive. There's probably another option I'm not thinking of.
The text was updated successfully, but these errors were encountered:
When building a blueprint (or a project), it's possible to hook functions into the site setup process using
blueprint.record
. which gets called when a Flask blueprint gets attached to an app. This is fine for getting at the site's underlying Flask app, but there's no reference to the site itself, or the project config.Here's my use case: I'm building a Tarbell blueprint where I want to use Flask-Assets and look for an
assets.yml
file in my project directory. I'd like to configure the extension (flask.ext.assets.Environment(app)
) inblueprint.record
, and then further configure it based ontarbell_config.py
orassets.yml
.Now, I could assume that
blueprint.py
will always be inproject/_blueprint
and climb up a directory, but that seems like bad practice.A couple options I can see:
site
argument inapp.register_blueprint
here. As far as I can tell, keyword arguments get passed along toblueprint.record
, so a reference to the current site could get passed around.Those aren't mutually exclusive. There's probably another option I'm not thinking of.
The text was updated successfully, but these errors were encountered: