Skip to content

Commit

Permalink
Get app debug status from app_config.
Browse files Browse the repository at this point in the history
Debug status defined in the ini file for Flask app. This helps in tests
where we don't want debug to be hardcoded when the flask stack is made.
  • Loading branch information
brew committed May 26, 2016
1 parent cf1575e commit 5ffa7b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 7 additions & 3 deletions ckan/config/middleware.py
Expand Up @@ -245,19 +245,23 @@ 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

# Do all the Flask-specific stuff before adding other middlewares

# secret key needed for flask-debug-toolbar
app.config['SECRET_KEY'] = '<replace with a secret key>'
app.debug = True
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
DebugToolbarExtension(app)

Expand Down
5 changes: 0 additions & 5 deletions ckanext/example_flask_iroutes/tests/test_routes.py
Expand Up @@ -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')
Expand Down

0 comments on commit 5ffa7b4

Please sign in to comment.