From 0549d22ec89778c2938ad48bba37f6eecc40a905 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 21 Apr 2013 18:42:58 +0200 Subject: [PATCH] Fixed manage.py runserver. The reload function did not work --- openslides/main.py | 19 ++++++++++++------- .../utils/management/commands/runserver.py | 6 +++--- openslides/utils/tornado_webserver.py | 6 ------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/openslides/main.py b/openslides/main.py index ba8733579..d6db7a85e 100644 --- a/openslides/main.py +++ b/openslides/main.py @@ -78,7 +78,7 @@ KEY_LENGTH = 30 _portable_db_path = object() -def process_options(argv=None, check_args=True): +def process_options(argv=None, manage_runserver=False): if argv is None: argv = sys.argv[1:] @@ -106,14 +106,19 @@ def process_options(argv=None, check_args=True): help="Show version and exit.") opts, args = parser.parse_args(argv) + + # Do not parse any argv if the script is started via manage.py runserver. + # This simulates the django runserver command + if manage_runserver: + opts.start_browser = False + opts.no_reload = False + return opts + if opts.version: print get_version() exit(0) - # Don't check for further args if we come from our custom management - # command, that always sets them - if args and check_args: - + if args: sys.stderr.write("This command does not take arguments!\n\n") parser.print_help() sys.exit(1) @@ -121,8 +126,8 @@ def process_options(argv=None, check_args=True): return opts -def main(argv=None, check_args=True): - opts = process_options(argv, check_args) +def main(argv=None, manage_runserver=False): + opts = process_options(argv, manage_runserver) _main(opts) diff --git a/openslides/utils/management/commands/runserver.py b/openslides/utils/management/commands/runserver.py index ac389cc37..83af12280 100644 --- a/openslides/utils/management/commands/runserver.py +++ b/openslides/utils/management/commands/runserver.py @@ -17,11 +17,11 @@ from openslides.main import main class Command(BaseCommand): - ''' + """ Start the application using the tornado webserver - ''' + """ help = 'Start the application using the tornado webserver' def handle(self, *args, **options): - main(check_args=False) + main(manage_runserver=True) diff --git a/openslides/utils/tornado_webserver.py b/openslides/utils/tornado_webserver.py index 065cccfc3..64ed6c762 100644 --- a/openslides/utils/tornado_webserver.py +++ b/openslides/utils/tornado_webserver.py @@ -38,12 +38,6 @@ class DjangoStaticFileHandler(StaticFileHandler): def run_tornado(addr, port, reload=False): - # We need to add the no-browser option to argv, otherwise with each reload - # a new browser will be opened (tornado simply re-executes Python using - # sys.executable and sys.argv) - if '--no-browser' not in sys.argv: - sys.argv.append('--no-browser') - # Don't try to read the command line args from openslides parse_command_line(args=[])