Fixed manage.py runserver.

The reload function did not work
This commit is contained in:
Oskar Hahn 2013-04-21 18:42:58 +02:00
parent 38558e9b03
commit 0549d22ec8
3 changed files with 15 additions and 16 deletions

View File

@ -78,7 +78,7 @@ KEY_LENGTH = 30
_portable_db_path = object() _portable_db_path = object()
def process_options(argv=None, check_args=True): def process_options(argv=None, manage_runserver=False):
if argv is None: if argv is None:
argv = sys.argv[1:] argv = sys.argv[1:]
@ -106,14 +106,19 @@ def process_options(argv=None, check_args=True):
help="Show version and exit.") help="Show version and exit.")
opts, args = parser.parse_args(argv) 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: if opts.version:
print get_version() print get_version()
exit(0) exit(0)
# Don't check for further args if we come from our custom management if args:
# command, that always sets them
if args and check_args:
sys.stderr.write("This command does not take arguments!\n\n") sys.stderr.write("This command does not take arguments!\n\n")
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
@ -121,8 +126,8 @@ def process_options(argv=None, check_args=True):
return opts return opts
def main(argv=None, check_args=True): def main(argv=None, manage_runserver=False):
opts = process_options(argv, check_args) opts = process_options(argv, manage_runserver)
_main(opts) _main(opts)

View File

@ -17,11 +17,11 @@ from openslides.main import main
class Command(BaseCommand): class Command(BaseCommand):
''' """
Start the application using the tornado webserver Start the application using the tornado webserver
''' """
help = 'Start the application using the tornado webserver' help = 'Start the application using the tornado webserver'
def handle(self, *args, **options): def handle(self, *args, **options):
main(check_args=False) main(manage_runserver=True)

View File

@ -38,12 +38,6 @@ class DjangoStaticFileHandler(StaticFileHandler):
def run_tornado(addr, port, reload=False): 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 # Don't try to read the command line args from openslides
parse_command_line(args=[]) parse_command_line(args=[])