summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-09-02 19:39:47 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-09-02 19:39:47 +0000
commit5bdf1da730368a16beaa077d91457ff625f06bc4 (patch)
tree49c2138caa03cee515bba898d7b800736c793e0d /django
parent92918b5ed74940c3cd64864473e0414ca9e134c9 (diff)
Fixed #394 -- Trailing-slash redirects now retain duplicate name-value query-string pairs, instead of the first of each pair. Added a QueryDict.urlencode() method to accomplish this. Updated the docs. Thanks for the good catch, mlambert
git-svn-id: http://code.djangoproject.com/svn/django/trunk@613 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/middleware/common.py3
-rw-r--r--django/utils/httpwrappers.py7
2 files changed, 8 insertions, 2 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 295855d73e..ee6b68be7e 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -4,7 +4,6 @@ from django.utils import httpwrappers
from django.core.mail import mail_managers
from django.views.core.flatfiles import flat_file
import md5, os
-from urllib import urlencode
class CommonMiddleware:
"""
@@ -49,7 +48,7 @@ class CommonMiddleware:
# Redirect
newurl = "%s://%s%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', new_url[0], new_url[1])
if request.GET:
- newurl += '?' + urlencode(request.GET)
+ newurl += '?' + request.GET.urlencode()
return httpwrappers.HttpResponseRedirect(newurl)
return None
diff --git a/django/utils/httpwrappers.py b/django/utils/httpwrappers.py
index 4a648d1849..107b63d40b 100644
--- a/django/utils/httpwrappers.py
+++ b/django/utils/httpwrappers.py
@@ -1,5 +1,6 @@
from Cookie import SimpleCookie
from pprint import pformat
+from urllib import urlencode
import datastructures
DEFAULT_MIME_TYPE = 'text/html'
@@ -117,6 +118,12 @@ class QueryDict(datastructures.MultiValueDict):
self.assert_synchronized()
return self._keys
+ def urlencode(self):
+ output = []
+ for k, list_ in self.data.items():
+ output.extend([urlencode({k: v}) for v in list_])
+ return '&'.join(output)
+
def parse_cookie(cookie):
if cookie == '':
return {}