diff --git a/ckan/config/middleware.py b/ckan/config/middleware.py index a21d75f5dba..754457c31a6 100644 --- a/ckan/config/middleware.py +++ b/ckan/config/middleware.py @@ -245,11 +245,16 @@ def __getattr__(self, name): def make_flask_stack(conf, **app_conf): - """ This has to pass the flask app through all the same middleware that - Pylons used """ + """ + This passes the flask app through most of the same middleware that Pylons + uses. + """ + + debug = app_conf.get('debug', True) root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) app = CKANFlask(__name__) + app.debug = debug app.template_folder = os.path.join(root, 'templates') app.app_ctx_globals_class = CKAN_AppCtxGlobals @@ -257,7 +262,6 @@ def make_flask_stack(conf, **app_conf): # secret key needed for flask-debug-toolbar app.config['SECRET_KEY'] = '' - app.debug = True app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False DebugToolbarExtension(app) diff --git a/ckanext/example_flask_iroutes/tests/test_routes.py b/ckanext/example_flask_iroutes/tests/test_routes.py index fa8110c76c8..e1feab9742f 100644 --- a/ckanext/example_flask_iroutes/tests/test_routes.py +++ b/ckanext/example_flask_iroutes/tests/test_routes.py @@ -37,11 +37,6 @@ def setup(self): self.app = helpers._get_test_app() flask_app = self._find_flask_app(self.app) - # Blueprints can't be registered after the app has been setup. For - # some reason, if debug is True, the app will have exited its initial - # state, and can't have new registrations. Set debug=False to ensure - # we can continue to register blueprints. - flask_app.debug = False # Install plugin and register its blueprint if not plugins.plugin_loaded('example_flask_iroutes'): plugins.load('example_flask_iroutes')