Skip to content

Commit d737216

Browse files
committed
Reverted the changes to django from branch/ssw/agenda/v4.70.
- Legacy-Id: 6276
1 parent 5206920 commit d737216

6 files changed

Lines changed: 21 additions & 93 deletions

File tree

django/core/management/commands/runserver.py

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
from django.core.management.base import BaseCommand, CommandError
22
from optparse import make_option
33
import os
4-
import socket
54
import sys
6-
import re
7-
8-
naiveip_re = r'^(?:(?P<addr>\d{1,3}(?:\.\d{1,3}){3}|\[[a-fA-F0-9:]+\]):)?(?P<port>\d+)$'
9-
DEFAULT_PORT = "8000"
105

116
class Command(BaseCommand):
127
option_list = BaseCommand.option_list + (
13-
make_option('--ipv6', '-6', action='store_true', dest='enable_ipv6', default=False,
14-
help='Force the use of IPv6 address.'),
158
make_option('--noreload', action='store_false', dest='use_reloader', default=True,
169
help='Tells Django to NOT use the auto-reloader.'),
1710
make_option('--adminmedia', dest='admin_media_path', default='',
@@ -27,32 +20,21 @@ def handle(self, addrport='', *args, **options):
2720
import django
2821
from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
2922
from django.core.handlers.wsgi import WSGIHandler
30-
enable_ipv6 = options.get('enable_ipv6')
31-
if enable_ipv6 and not hasattr(socket, 'AF_INET6'):
32-
raise CommandError("Your Python does not support IPv6.")
33-
3423
if args:
3524
raise CommandError('Usage is runserver %s' % self.args)
3625
if not addrport:
3726
addr = ''
38-
port = DEFAULT_PORT
27+
port = '8000'
3928
else:
40-
m = re.match(naiveip_re, addrport)
41-
if m is None:
42-
raise CommandError("%r is not a valid port number or address:port pair." % addrport)
43-
addr, port = m.groups()
44-
45-
if not port.isdigit():
46-
raise CommandError("%r is not a valid port number." % port)
47-
if addr:
48-
if addr[0] == '[' and addr[-1] == ']':
49-
enable_ipv6 = True
50-
addr = addr[1:-1]
51-
elif enable_ipv6:
52-
raise CommandError("IPv6 addresses must be surrounded with brackets")
29+
try:
30+
addr, port = addrport.split(':')
31+
except ValueError:
32+
addr, port = '', addrport
5333
if not addr:
5434
addr = '127.0.0.1'
55-
addr = (enable_ipv6 and '::1') or '127.0.0.1'
35+
36+
if not port.isdigit():
37+
raise CommandError("%r is not a valid port number." % port)
5638

5739
use_reloader = options.get('use_reloader', True)
5840
admin_media_path = options.get('admin_media_path', '')
@@ -65,8 +47,7 @@ def inner_run():
6547
print "Validating models..."
6648
self.validate(display_num_errors=True)
6749
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
68-
fmt_addr = (enable_ipv6 and '[%s]' % addr) or addr
69-
print "Development server is running at http://%s:%s/" % (fmt_addr, port)
50+
print "Development server is running at http://%s:%s/" % (addr, port)
7051
print "Quit the server with %s." % quit_command
7152

7253
# django.core.management.base forces the locale to en-us. We should
@@ -76,7 +57,7 @@ def inner_run():
7657

7758
try:
7859
handler = AdminMediaHandler(WSGIHandler(), admin_media_path)
79-
run(addr, int(port), handler, enable_ipv6=enable_ipv6)
60+
run(addr, int(port), handler)
8061
except WSGIServerException, e:
8162
# Use helpful error messages instead of ugly tracebacks.
8263
ERRORS = {

django/core/management/commands/shell.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ class Command(NoArgsCommand):
66
option_list = NoArgsCommand.option_list + (
77
make_option('--plain', action='store_true', dest='plain',
88
help='Tells Django to use plain Python, not IPython.'),
9-
make_option('--test', action='store_true', dest='test',
10-
help='Tells Django to load test environment'),
119
)
1210
help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
1311

@@ -19,19 +17,6 @@ def handle_noargs(self, **options):
1917
from django.db.models.loading import get_models
2018
loaded_models = get_models()
2119

22-
use_test = options.get('test', False)
23-
if use_test:
24-
from django import test
25-
print "Setting up test environment"
26-
test.utils.setup_test_environment() # Setup the environment
27-
from django.db import connection
28-
print "Creating test db"
29-
db = connection.creation.create_test_db() # Create the test db
30-
print "Created test db, now loading data"
31-
from django.core.management import call_command
32-
call_command('loaddata', *['list', 'of', 'fixtures', 'here']) # Load fixtures
33-
print "Created test db"
34-
3520
use_plain = options.get('plain', False)
3621

3722
try:
@@ -72,12 +57,12 @@ def handle_noargs(self, **options):
7257

7358
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
7459
# conventions and get $PYTHONSTARTUP first then import user.
75-
if not use_plain:
76-
pythonrc = os.environ.get("PYTHONSTARTUP")
77-
if pythonrc and os.path.isfile(pythonrc):
78-
try:
79-
execfile(pythonrc)
80-
except NameError:
60+
if not use_plain:
61+
pythonrc = os.environ.get("PYTHONSTARTUP")
62+
if pythonrc and os.path.isfile(pythonrc):
63+
try:
64+
execfile(pythonrc)
65+
except NameError:
8166
pass
8267
# This will import .pythonrc.py as a side-effect
8368
import user

django/core/management/commands/testserver.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class Command(BaseCommand):
77
make_option('--addrport', action='store', dest='addrport',
88
type='string', default='',
99
help='port number or ipaddr:port to run the server on'),
10-
make_option('--ipv6', '-6', action='store_true', dest='enable_ipv6', default=False,
11-
help='Forces IPv6 support.'),
1210
)
1311
help = 'Runs a development server with data from the given fixture(s).'
1412
args = '[fixture ...]'
@@ -32,4 +30,4 @@ def handle(self, *fixture_labels, **options):
3230
# a strange error -- it causes this handle() method to be called
3331
# multiple times.
3432
shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
35-
call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False, enable_ipv6=options['enable_ipv6'])
33+
call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False)

django/core/servers/basehttp.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import mimetypes
1212
import os
1313
import re
14-
import socket
1514
import stat
1615
import sys
1716
import urllib
@@ -715,12 +714,8 @@ def __call__(self, environ, start_response):
715714
start_response(status, headers.items())
716715
return output
717716

718-
class WSGIServerV6(WSGIServer):
719-
address_family = socket.AF_INET6
720-
721-
def run(addr, port, wsgi_handler, enable_ipv6=False):
717+
def run(addr, port, wsgi_handler):
722718
server_address = (addr, port)
723-
server_class = (enable_ipv6 and WSGIServerV6) or WSGIServer
724-
httpd = server_class(server_address, WSGIRequestHandler)
719+
httpd = WSGIServer(server_address, WSGIRequestHandler)
725720
httpd.set_app(wsgi_handler)
726721
httpd.serve_forever()

django/http/__init__.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
absolute_http_url_re = re.compile(r"^https?://", re.I)
2323

24-
class Http403(Exception):
25-
pass
26-
2724
class Http404(Exception):
2825
pass
2926

@@ -78,15 +75,6 @@ def build_absolute_uri(self, location=None):
7875
location = urljoin(current_uri, location)
7976
return iri_to_uri(location)
8077

81-
# added by mcr@sandelman.ca
82-
def get_host_protocol(self):
83-
"""
84-
Builds an absolute URI for the server.
85-
"""
86-
current_uri = '%s://%s' % (self.is_secure() and 'https' or 'http',
87-
self.get_host())
88-
return iri_to_uri(current_uri)
89-
9078
def is_secure(self):
9179
return os.environ.get("HTTPS") == "on"
9280

@@ -425,22 +413,10 @@ def delete_cookie(self, key, path='/', domain=None):
425413
def _get_content(self):
426414
if self.has_header('Content-Encoding'):
427415
return ''.join(self._container)
428-
# the /meeting/75/agenda/mip4 test case results in
429-
# self._container == [None]
430-
f1 = ''
431-
try:
432-
f1 = ''.join(self._container)
433-
except:
434-
pass
435-
#import sys
436-
#sys.stdout.write("container: %s" % (self._container))
437-
return smart_str(f1, self._charset)
416+
return smart_str(''.join(self._container), self._charset)
438417

439418
def _set_content(self, value):
440-
if value is None:
441-
self._container = ['']
442-
else:
443-
self._container = [value]
419+
self._container = [value]
444420
self._is_string = True
445421

446422
content = property(_get_content, _set_content)

django/test/testcases.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,6 @@ class TestCase(TransactionTestCase):
533533
to use TransactionTestCase, if you need transaction management inside a test.
534534
"""
535535

536-
# fixtures_loaded is for AgendaTransactionTestCase.
537-
fixtures_loaded = False
538-
539536
def _fixture_setup(self):
540537
if not connections_support_transactions():
541538
return super(TestCase, self)._fixture_setup()
@@ -548,10 +545,6 @@ def _fixture_setup(self):
548545
databases = [DEFAULT_DB_ALIAS]
549546

550547
for db in databases:
551-
# should be a no-op, but another test case method might have left junk.
552-
call_command('flush', verbosity=0, interactive=False, database=db)
553-
TestCase.fixtures_loaded = False
554-
555548
transaction.enter_transaction_management(using=db)
556549
transaction.managed(True, using=db)
557550
disable_transaction_methods()

0 commit comments

Comments
 (0)