Ticket #113: diff_output.txt

File diff_output.txt, 2.4 KB (added by Jason Huggins, 10 years ago)

Here's the new patch...

Line 
1Index: management.py
2===================================================================
3--- management.py       (revision 262)
4+++ management.py       (working copy)
5@@ -417,26 +417,30 @@
6 
7 def runserver(port):
8     "Starts a lightweight Web server for development."
9-    from django.core.servers.basehttp import run, WSGIServerException
10-    from django.core.handlers.wsgi import AdminMediaHandler, WSGIHandler
11-    from django.conf.settings import SETTINGS_MODULE
12-    if not port.isdigit():
13-        sys.stderr.write("Error: %r is not a valid port number.\n" % port)
14-        sys.exit(1)
15-    print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE)
16-    print "Go to http://127.0.0.1:%s/ for Django." % port
17-    try:
18-        run(int(port), AdminMediaHandler(WSGIHandler()))
19-    except WSGIServerException, e:
20-        # Use helpful error messages instead of ugly tracebacks.
21-        ERRORS = {
22-            13: "You don't have permission to access that port.",
23-            98: "That port is already in use.",
24-        }
25+    def run():
26+        from django.core.servers.basehttp import run, WSGIServerException
27+        from django.core.handlers.wsgi import AdminMediaHandler, WSGIHandler
28+        from django.conf.settings import SETTINGS_MODULE
29+        if not port.isdigit():
30+            sys.stderr.write("Error: %r is not a valid port number.\n" % port)
31+            sys.exit(1)
32+        print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE)
33+        print "Go to http://127.0.0.1:%s/ for Django." % port
34         try:
35-            error_text = ERRORS[e.args[0].args[0]]
36-        except (AttributeError, KeyError):
37-            error_text = str(e)
38-        sys.stderr.write("Error: %s\n" % error_text)
39-        sys.exit(1)
40+            run(int(port), AdminMediaHandler(WSGIHandler()))
41+        except WSGIServerException, e:
42+            # Use helpful error messages instead of ugly tracebacks.
43+            ERRORS = {
44+                13: "You don't have permission to access that port.",
45+                98: "That port is already in use.",
46+            }
47+            try:
48+                error_text = ERRORS[e.args[0].args[0]]
49+            except (AttributeError, KeyError):
50+                error_text = str(e)
51+            sys.stderr.write("Error: %s\n" % error_text)
52+            sys.exit(1)
53+    from django.utils import autoreload
54+    autoreload.main(run)
55+
56 runserver.args = '[optional port number]'
Back to Top