Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
Don't override debug setting if set in config, else use 'use_debugger…
Browse files Browse the repository at this point in the history
…' value (previous default) - Fixed #40.  Also expose 'passthrough_errors' setting -  Fixed #15.
  • Loading branch information
techniq committed Sep 22, 2012
1 parent c08c9b6 commit 637aa21
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions flask_script.py
Expand Up @@ -312,13 +312,15 @@ class Server(Command):
:param threaded: should the process handle each request in a separate
thread?
:param processes: number of processes to spawn
:param passthrough_errors: disable the error catching. This means that the server will die on errors but it can be useful to hook debuggers in (pdb etc.)
:param options: :func:`werkzeug.run_simple` options.
"""

description = 'Runs the Flask development server i.e. app.run()'

def __init__(self, host='127.0.0.1', port=5000, use_debugger=True,
use_reloader=True, threaded=False, processes=1, **options):
use_reloader=True, threaded=False, processes=1,
passthrough_errors=False, **options):

self.port = port
self.host = host
Expand All @@ -327,6 +329,7 @@ def __init__(self, host='127.0.0.1', port=5000, use_debugger=True,
self.server_options = options
self.threaded = threaded
self.processes = processes
self.passthrough_errors = passthrough_errors

def get_options(self):

Expand All @@ -349,6 +352,11 @@ def get_options(self):
dest='processes',
type=int,
default=self.processes),

Option('--passthrough-errors',
action='store_true',
dest='passthrough_errors',
default=self.passthrough_errors),
)

if self.use_debugger:
Expand Down Expand Up @@ -378,17 +386,18 @@ def get_options(self):
return options

def handle(self, app, host, port, use_debugger, use_reloader,
threaded, processes):
threaded, processes, passthrough_errors):
# we don't need to run the server in request context
# so just run it directly

app.run(host=host,
port=port,
debug=use_debugger,
debug=app.config.get('DEBUG', use_debugger),
use_debugger=use_debugger,
use_reloader=use_reloader,
threaded=threaded,
processes=processes,
passthrough_errors=passthrough_errors,
**self.server_options)


Expand Down Expand Up @@ -441,7 +450,6 @@ def __init__(self, app=None, with_default_commands=None, usage=None):

self.parent = None


def add_default_commands(self):
"""
Adds the shell and runserver default commands. To override these
Expand Down Expand Up @@ -486,8 +494,8 @@ def create_app(config=None):
self._options.append(Option(*args, **kwargs))

def create_app(self, **kwargs):
# Sub-manager, defer to parent Manager
if self.parent:
# Sub-manager, defer to parent Manager
return self.parent.create_app(**kwargs)

if isinstance(self.app, Flask):
Expand Down

0 comments on commit 637aa21

Please sign in to comment.