danjac/Flask-Script — Issue #3: missing before_request trigger
Author: munhitsu
Created: 2011-12-13 23:03:46+00:00
State: open

I've found it useful to have before_request triggered before shell execution.
It's even more important as teardown_request is automatically executed by exit() from shell.

diff --git a/flaskext/script.py b/flaskext/script.py
index 5a3996f..2ff3148 100644
--- a/flaskext/script.py
+++ b/flaskext/script.py
@@ -190,7 +190,9 @@ class Command(object):
a test request context.
"""
with app.test_request_context():
+ app.preprocess_request()
self.run(*args, **kwargs)
+ app.process_response(app.response_class())

def run(self):