sloria / konch

Configures your Python shell.
https://konch.readthedocs.io/
MIT License
406 stars 18 forks source link

Fix to fire Flask.before_request and Flask.after_request functions #28

Closed lokeshmeher closed 6 years ago

lokeshmeher commented 6 years ago

According to the documentation for working with shell in Flask (link):

By just creating a request context, you still don’t have run the code that is normally run before a request. This might result in your database being unavailable if you are connecting to the database in a before-request callback or the current user not being stored on the g object etc.

This could be fixed by calling app.preprocess_request() explicitly. Similarly, to trigger the after_request functions, a trick is suggested like so: app.process_response(app.response_class()).

sloria commented 6 years ago

Thanks!