pallets / flask

The Python micro framework for building web applications.
https://flask.palletsprojects.com
BSD 3-Clause "New" or "Revised" License
67.56k stars 16.15k forks source link

Request to add a callback hook while registering blueprint. #691

Closed tonyseek closed 7 years ago

tonyseek commented 11 years ago

Should it send a signal while register_blueprint been calling? Sometime we may expect to initialize something while a new blueprint been loading.

apiguy commented 11 years ago

+1 for this. Would be very helpful for extensions. @tonyseek is there a pull request incoming?

untitaker commented 11 years ago

Is #695 sufficient?

mitsuhiko commented 11 years ago

Not sure how that is useful? Wouldn't that run into bootstrapping issues as blueprints can only be registered as the application is instanciated? In that case I would assume the better approach is to just subclass Flask and customize the register method?

untitaker commented 11 years ago

Can anybody post some concrete examples where this hook might be useful, so @mitsuhiko is convinced?

rcrowell commented 9 years ago

I would like to decorate all of a blueprint's view functions with a custom @as_json function before registering the blueprint, without having to write @as_json on each one individually.

I was hoping to get a callback during blueprint-registration time to make these changes. Is there a better way?

igarcez commented 4 years ago

I would like to add db related initialization (creating indexes) in the blueprint registration callback