Author: jacob
Date: 2008-08-29 11:49:19 -0500 (Fri, 29 Aug 2008)
New Revision: 8705

Modified:
   django/trunk/django/http/__init__.py
   django/trunk/tests/regressiontests/httpwrappers/tests.py
Log:
Fixed #8278: fixed `QueryDict.update(QueryDict)`. Thanks, julien.

Modified: django/trunk/django/http/__init__.py
===================================================================
--- django/trunk/django/http/__init__.py        2008-08-29 16:46:46 UTC (rev 
8704)
+++ django/trunk/django/http/__init__.py        2008-08-29 16:49:19 UTC (rev 
8705)
@@ -211,8 +211,13 @@
     def update(self, other_dict):
         self._assert_mutable()
         f = lambda s: str_to_unicode(s, self.encoding)
-        d = dict([(f(k), f(v)) for k, v in other_dict.items()])
-        MultiValueDict.update(self, d)
+        if hasattr(other_dict, 'lists'):
+            for key, valuelist in other_dict.lists():
+                for value in valuelist:
+                    MultiValueDict.update(self, {f(key): f(value)})
+        else:
+            d = dict([(f(k), f(v)) for k, v in other_dict.items()])
+            MultiValueDict.update(self, d)
 
     def pop(self, key, *args):
         self._assert_mutable()

Modified: django/trunk/tests/regressiontests/httpwrappers/tests.py
===================================================================
--- django/trunk/tests/regressiontests/httpwrappers/tests.py    2008-08-29 
16:46:46 UTC (rev 8704)
+++ django/trunk/tests/regressiontests/httpwrappers/tests.py    2008-08-29 
16:49:19 UTC (rev 8705)
@@ -436,6 +436,14 @@
 ...
 UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format
 
+#
+# Regression test for #8278: QueryDict.update(QueryDict)
+#
+>>> x = QueryDict("a=1&a=2", mutable=True)
+>>> y = QueryDict("a=3&a=4")
+>>> x.update(y)
+>>> x.getlist('a')
+[u'1', u'2', u'3', u'4']
 """
 
 from django.http import QueryDict, HttpResponse


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to