From 5bdf1da730368a16beaa077d91457ff625f06bc4 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 2 Sep 2005 19:39:47 +0000 Subject: 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 --- django/utils/httpwrappers.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'django/utils') 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 {} -- cgit v1.3