Django

Code

Changeset 266

Show
Ignore:
Timestamp:
07/20/05 23:08:54 (3 years ago)
Author:
adrian
Message:

Added auto-reload to standalone server! Fixes #113. Thanks very much to Jason Huggins for the patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management.py

    r264 r266  
    420420    from django.core.servers.basehttp import run, WSGIServerException 
    421421    from django.core.handlers.wsgi import AdminMediaHandler, WSGIHandler 
    422     from django.conf.settings import SETTINGS_MODULE 
    423422    if not port.isdigit(): 
    424423        sys.stderr.write("Error: %r is not a valid port number.\n" % port) 
    425424        sys.exit(1) 
    426     print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE) 
    427     print "Go to http://127.0.0.1:%s/ for Django." % port 
    428     print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." 
    429     try: 
    430         run(int(port), AdminMediaHandler(WSGIHandler())) 
    431     except WSGIServerException, e: 
    432         # Use helpful error messages instead of ugly tracebacks. 
    433         ERRORS = { 
    434             13: "You don't have permission to access that port.", 
    435             98: "That port is already in use.", 
    436         } 
     425    def inner_run(): 
     426        from django.conf.settings import SETTINGS_MODULE 
     427        print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE) 
     428        print "Go to http://127.0.0.1:%s/ for Django." % port 
     429        print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." 
    437430        try: 
    438             error_text = ERRORS[e.args[0].args[0]] 
    439         except (AttributeError, KeyError): 
    440             error_text = str(e) 
    441         sys.stderr.write("Error: %s\n" % error_text) 
    442         sys.exit(1) 
    443     except KeyboardInterrupt: 
    444         sys.exit(0) 
     431            run(int(port), AdminMediaHandler(WSGIHandler())) 
     432        except WSGIServerException, e: 
     433            # Use helpful error messages instead of ugly tracebacks. 
     434            ERRORS = { 
     435                13: "You don't have permission to access that port.", 
     436                98: "That port is already in use.", 
     437            } 
     438            try: 
     439                error_text = ERRORS[e.args[0].args[0]] 
     440            except (AttributeError, KeyError): 
     441                error_text = str(e) 
     442            sys.stderr.write("Error: %s\n" % error_text) 
     443            sys.exit(1) 
     444        except KeyboardInterrupt: 
     445            sys.exit(0) 
     446    from django.utils import autoreload 
     447    autoreload.main(inner_run) 
    445448runserver.args = '[optional port number]'