mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Changed/fixed the way Django handles SCRIPT_NAME and PATH_INFO (or
equivalents). Basically, URL resolving will only use the PATH_INFO and the SCRIPT_NAME will be prepended by reverse() automatically. Allows for more portable development and installation. Also exposes SCRIPT_NAME in the HttpRequest instance. There are a number of cases where things don't work completely transparently, so mod_python and fastcgi users should read the relevant docs. Fixed #285, #1516, #3414. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8015 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -7,7 +7,8 @@ except ImportError:
|
||||
|
||||
from django import http
|
||||
from django.core import signals
|
||||
from django.core.handlers.base import BaseHandler
|
||||
from django.core.handlers import base
|
||||
from django.core.urlresolvers import set_script_prefix
|
||||
from django.dispatch import dispatcher
|
||||
from django.utils import datastructures
|
||||
from django.utils.encoding import force_unicode
|
||||
@@ -74,9 +75,14 @@ def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0):
|
||||
|
||||
class WSGIRequest(http.HttpRequest):
|
||||
def __init__(self, environ):
|
||||
script_name = base.get_script_name(environ)
|
||||
path_info = force_unicode(environ.get('PATH_INFO', '/'))
|
||||
self.environ = environ
|
||||
self.path = force_unicode(environ['PATH_INFO'])
|
||||
self.path_info = path_info
|
||||
self.path = '%s%s' % (script_name, path_info)
|
||||
self.META = environ
|
||||
self.META['PATH_INFO'] = path_info
|
||||
self.META['SCRIPT_NAME'] = script_name
|
||||
self.method = environ['REQUEST_METHOD'].upper()
|
||||
|
||||
def __repr__(self):
|
||||
@@ -178,7 +184,7 @@ class WSGIRequest(http.HttpRequest):
|
||||
REQUEST = property(_get_request)
|
||||
raw_post_data = property(_get_raw_post_data)
|
||||
|
||||
class WSGIHandler(BaseHandler):
|
||||
class WSGIHandler(base.BaseHandler):
|
||||
initLock = Lock()
|
||||
request_class = WSGIRequest
|
||||
|
||||
@@ -194,6 +200,7 @@ class WSGIHandler(BaseHandler):
|
||||
self.load_middleware()
|
||||
self.initLock.release()
|
||||
|
||||
set_script_prefix(base.get_script_name(environ))
|
||||
dispatcher.send(signal=signals.request_started)
|
||||
try:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user