Changeset 7995
- Timestamp:
- 07/19/08 14:37:55 (2 months ago)
- Files:
-
- django/trunk/django/core/handlers/base.py (modified) (3 diffs)
- django/trunk/django/core/handlers/modpython.py (modified) (3 diffs)
- django/trunk/django/core/handlers/wsgi.py (modified) (3 diffs)
- django/trunk/django/core/urlresolvers.py (modified) (1 diff)
- django/trunk/django/http/__init__.py (modified) (2 diffs)
- django/trunk/django/test/client.py (modified) (1 diff)
- django/trunk/django/utils/thread_support.py (deleted)
- django/trunk/django/utils/translation/trans_real.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/handlers/base.py
r7992 r7995 4 4 from django.core import signals 5 5 from django.dispatch import dispatcher 6 from django.utils.encoding import force_unicode7 6 8 7 class BaseHandler(object): … … 75 74 resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) 76 75 try: 77 callback, callback_args, callback_kwargs = resolver.resolve( 78 request.path_info) 76 callback, callback_args, callback_kwargs = resolver.resolve(request.path) 79 77 80 78 # Apply view middleware … … 173 171 return response 174 172 175 def get_script_name(environ):176 """177 Returns the equivalent of the HTTP request's SCRIPT_NAME environment178 variable. If Apache mod_rewrite has been used, returns what would have been179 the script name prior to any rewriting (so it's the script name as seen180 from the client's perspective).181 182 Note: this isn't used by the mod_python handler, since the equivalent of183 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 to187 # SCRIPT_NAME before applying any rewrites.188 script_url = force_unicode(environ.get('SCRIPT_URL', ''))189 if script_url:190 return script_url191 return force_unicode(environ.get('SCRIPT_NAME', ''))192 django/trunk/django/core/handlers/modpython.py
r7991 r7995 17 17 self._req = req 18 18 self.path = force_unicode(req.uri) 19 root = req.get_options().get('django.root', '')20 self._django_root = root21 # req.path_info isn't necessarily computed correctly in all22 # circumstances (it's out of mod_python's control a bit), so we use23 # 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.path28 19 29 20 def __repr__(self): … … 110 101 'CONTENT_TYPE': self._req.content_type, # This may be wrong 111 102 'GATEWAY_INTERFACE': 'CGI/1.1', 112 'PATH_INFO': self. path_info,103 'PATH_INFO': self._req.path_info, 113 104 'PATH_TRANSLATED': None, # Not supported 114 105 'QUERY_STRING': self._req.args, … … 118 109 'REMOTE_USER': self._req.user, 119 110 'REQUEST_METHOD': self._req.method, 120 'SCRIPT_NAME': self._django_root,111 'SCRIPT_NAME': None, # Not supported 121 112 'SERVER_NAME': self._req.server.server_hostname, 122 113 'SERVER_PORT': self._req.server.port, django/trunk/django/core/handlers/wsgi.py
r7991 r7995 8 8 from django import http 9 9 from django.core import signals 10 from django.core.handlers import base10 from django.core.handlers.base import BaseHandler 11 11 from django.dispatch import dispatcher 12 12 from django.utils import datastructures … … 75 75 class WSGIRequest(http.HttpRequest): 76 76 def __init__(self, environ): 77 script_name = base.get_script_name()78 path_info = force_unicode(environ.get('PATH_INFO', '/'))79 77 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']) 82 79 self.META = environ 83 self.META['PATH_INFO'] = path_info84 self.META['SCRIPT_NAME'] = script_name85 80 self.method = environ['REQUEST_METHOD'].upper() 86 81 … … 184 179 raw_post_data = property(_get_raw_post_data) 185 180 186 class WSGIHandler( base.BaseHandler):181 class WSGIHandler(BaseHandler): 187 182 initLock = Lock() 188 183 request_class = WSGIRequest django/trunk/django/core/urlresolvers.py
r7991 r7995 292 292 return get_resolver(urlconf).resolve(path) 293 293 294 def reverse(viewname, urlconf=None, args=None, kwargs=None , prefix=u'/'):294 def reverse(viewname, urlconf=None, args=None, kwargs=None): 295 295 args = args or [] 296 296 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)) 299 298 300 299 def clear_url_caches(): django/trunk/django/http/__init__.py
r7991 r7995 32 32 self.GET, self.POST, self.COOKIES, self.META, self.FILES = {}, {}, {}, {}, {} 33 33 self.path = '' 34 self.path_info = ''35 34 self.method = None 36 35 … … 444 443 else: 445 444 return s 446 django/trunk/django/test/client.py
r7991 r7995 191 191 'QUERY_STRING': '', 192 192 'REQUEST_METHOD': 'GET', 193 'SCRIPT_NAME': '',193 'SCRIPT_NAME': None, 194 194 'SERVER_NAME': 'testserver', 195 195 'SERVER_PORT': 80, django/trunk/django/utils/translation/trans_real.py
r7993 r7995 9 9 10 10 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' 12 23 13 24 # Translations are cached in a dictionary for every language+app tuple.
