Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signal/hook for blueprint loaded or site initialized #422

Open
eyeseast opened this issue May 12, 2016 · 0 comments
Open

Add signal/hook for blueprint loaded or site initialized #422

eyeseast opened this issue May 12, 2016 · 0 comments
Milestone

Comments

@eyeseast
Copy link
Contributor

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_blueprint here. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant