From eb001bf6def1930c036657b01ac9385a63637728 Mon Sep 17 00:00:00 2001 From: Nick Zaccardi Date: Sat, 5 Dec 2015 18:37:03 -0500 Subject: [PATCH] Enable applications to start the debugger --- flask/cli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flask/cli.py b/flask/cli.py index 360ce12e..1def8a3d 100644 --- a/flask/cli.py +++ b/flask/cli.py @@ -105,6 +105,15 @@ class DispatchingApp(object): of the Werkzeug debugger means that it shows up in the browser. """ + @property + def debug(self): + try: + return self._app.debug + except AttributeError as e: + print('Application not created yet, can\'t determine debug ' + 'status.') + return False + def __init__(self, loader, use_eager_loading=False): self.loader = loader self._app = None @@ -421,6 +430,10 @@ def run_command(info, host, port, reload, debugger, eager_loading, if info.debug is not None: print(' * Forcing debug %s' % (info.debug and 'on' or 'off')) + if app.debug: + debugger = True + print(' * Debug activated by application configuration.') + run_simple(host, port, app, use_reloader=reload, use_debugger=debugger, threaded=with_threads)