Skip to content

Commit 46fb825

Browse files
author
mtredinnick
committed
Revert [7991] - [7993]. I was committing from the wrong branch. Sorry 'bout
that, folks. :-( git-svn-id: http://code.djangoproject.com/svn/django/trunk@7995 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 828f0fa commit 46fb825

File tree

8 files changed

+21
-59
lines changed

8 files changed

+21
-59
lines changed

django/core/handlers/base.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from django import http
44
from django.core import signals
55
from django.dispatch import dispatcher
6-
from django.utils.encoding import force_unicode
76

87
class BaseHandler(object):
98
# Changes that are always applied to a response (in this order).
@@ -74,8 +73,7 @@ def get_response(self, request):
7473

7574
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
7675
try:
77-
callback, callback_args, callback_kwargs = resolver.resolve(
78-
request.path_info)
76+
callback, callback_args, callback_kwargs = resolver.resolve(request.path)
7977

8078
# Apply view middleware
8179
for middleware_method in self._view_middleware:
@@ -172,21 +170,3 @@ def apply_response_fixes(self, request, response):
172170
response = func(request, response)
173171
return response
174172

175-
def get_script_name(environ):
176-
"""
177-
Returns the equivalent of the HTTP request's SCRIPT_NAME environment
178-
variable. If Apache mod_rewrite has been used, returns what would have been
179-
the script name prior to any rewriting (so it's the script name as seen
180-
from the client's perspective).
181-
182-
Note: this isn't used by the mod_python handler, since the equivalent of
183-
SCRIPT_NAME isn't available there.
184-
"""
185-
if not environ.get('DJANGO_USE_POST_REWRITE'):
186-
# If mod_rewrite had a whack at the URL, Apache set SCRIPT_URL to
187-
# SCRIPT_NAME before applying any rewrites.
188-
script_url = force_unicode(environ.get('SCRIPT_URL', ''))
189-
if script_url:
190-
return script_url
191-
return force_unicode(environ.get('SCRIPT_NAME', ''))
192-

django/core/handlers/modpython.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ class ModPythonRequest(http.HttpRequest):
1616
def __init__(self, req):
1717
self._req = req
1818
self.path = force_unicode(req.uri)
19-
root = req.get_options().get('django.root', '')
20-
self._django_root = root
21-
# req.path_info isn't necessarily computed correctly in all
22-
# circumstances (it's out of mod_python's control a bit), so we use
23-
# req.uri and some string manipulations to get the right value.
24-
if root and req.uri.startswith(root):
25-
self.path_info = force_unicode(req.uri[len(root):])
26-
else:
27-
self.path_info = self.path
2819

2920
def __repr__(self):
3021
# Since this is called as part of error handling, we need to be very
@@ -109,15 +100,15 @@ def _get_meta(self):
109100
'CONTENT_LENGTH': self._req.clength, # This may be wrong
110101
'CONTENT_TYPE': self._req.content_type, # This may be wrong
111102
'GATEWAY_INTERFACE': 'CGI/1.1',
112-
'PATH_INFO': self.path_info,
103+
'PATH_INFO': self._req.path_info,
113104
'PATH_TRANSLATED': None, # Not supported
114105
'QUERY_STRING': self._req.args,
115106
'REMOTE_ADDR': self._req.connection.remote_ip,
116107
'REMOTE_HOST': None, # DNS lookups not supported
117108
'REMOTE_IDENT': self._req.connection.remote_logname,
118109
'REMOTE_USER': self._req.user,
119110
'REQUEST_METHOD': self._req.method,
120-
'SCRIPT_NAME': self._django_root,
111+
'SCRIPT_NAME': None, # Not supported
121112
'SERVER_NAME': self._req.server.server_hostname,
122113
'SERVER_PORT': self._req.server.port,
123114
'SERVER_PROTOCOL': self._req.protocol,

django/core/handlers/wsgi.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from django import http
99
from django.core import signals
10-
from django.core.handlers import base
10+
from django.core.handlers.base import BaseHandler
1111
from django.dispatch import dispatcher
1212
from django.utils import datastructures
1313
from django.utils.encoding import force_unicode
@@ -74,14 +74,9 @@ def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0):
7474

7575
class WSGIRequest(http.HttpRequest):
7676
def __init__(self, environ):
77-
script_name = base.get_script_name()
78-
path_info = force_unicode(environ.get('PATH_INFO', '/'))
7977
self.environ = environ
80-
self.path_info = path_info
81-
self.path = '%s%s' % (script_name, path_info)
78+
self.path = force_unicode(environ['PATH_INFO'])
8279
self.META = environ
83-
self.META['PATH_INFO'] = path_info
84-
self.META['SCRIPT_NAME'] = script_name
8580
self.method = environ['REQUEST_METHOD'].upper()
8681

8782
def __repr__(self):
@@ -183,7 +178,7 @@ def _get_raw_post_data(self):
183178
REQUEST = property(_get_request)
184179
raw_post_data = property(_get_raw_post_data)
185180

186-
class WSGIHandler(base.BaseHandler):
181+
class WSGIHandler(BaseHandler):
187182
initLock = Lock()
188183
request_class = WSGIRequest
189184

django/core/urlresolvers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,10 @@ def reverse_helper(self, lookup_view, *args, **kwargs):
291291
def resolve(path, urlconf=None):
292292
return get_resolver(urlconf).resolve(path)
293293

294-
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=u'/'):
294+
def reverse(viewname, urlconf=None, args=None, kwargs=None):
295295
args = args or []
296296
kwargs = kwargs or {}
297-
return iri_to_uri(prefix +
298-
get_resolver(urlconf).reverse(viewname, *args, **kwargs))
297+
return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs))
299298

300299
def clear_url_caches():
301300
global _resolver_cache

django/http/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class HttpRequest(object):
3131
def __init__(self):
3232
self.GET, self.POST, self.COOKIES, self.META, self.FILES = {}, {}, {}, {}, {}
3333
self.path = ''
34-
self.path_info = ''
3534
self.method = None
3635

3736
def __repr__(self):
@@ -443,4 +442,3 @@ def str_to_unicode(s, encoding):
443442
return unicode(s, encoding, 'replace')
444443
else:
445444
return s
446-

django/test/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def request(self, **request):
190190
'PATH_INFO': '/',
191191
'QUERY_STRING': '',
192192
'REQUEST_METHOD': 'GET',
193-
'SCRIPT_NAME': '',
193+
'SCRIPT_NAME': None,
194194
'SERVER_NAME': 'testserver',
195195
'SERVER_PORT': 80,
196196
'SERVER_PROTOCOL': 'HTTP/1.1',

django/utils/thread_support.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

django/utils/translation/trans_real.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@
88
from cStringIO import StringIO
99

1010
from django.utils.safestring import mark_safe, SafeData
11-
from django.utils.thread_support import currentThread
11+
12+
try:
13+
import threading
14+
hasThreads = True
15+
except ImportError:
16+
hasThreads = False
17+
18+
if hasThreads:
19+
currentThread = threading.currentThread
20+
else:
21+
def currentThread():
22+
return 'no threading'
1223

1324
# Translations are cached in a dictionary for every language+app tuple.
1425
# The active translations are stored by threadid to make them thread local.

0 commit comments

Comments
 (0)