summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-08-16 02:17:55 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-08-16 02:17:55 +0000
commit2b82a3bcfc757c2bdafca6c5d9930201deed00cf (patch)
treea712fa25672effd2da968ddef0e12b5d8d41932d
parentddc156bca2519dfb60974f49d085826d0a778f77 (diff)
Fixed #7331 -- Made `QueryDict.iteritems` behave like `QueryDict.items`, thanks jurev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/datastructures.py8
-rw-r--r--tests/regressiontests/datastructures/tests.py2
2 files changed, 10 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index f27bc1cfff..818731ba04 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -266,6 +266,14 @@ class MultiValueDict(dict):
"""
return [(key, self[key]) for key in self.keys()]
+ def iteritems(self):
+ """
+ Yields (key, value) pairs, where value is the last item in the list
+ associated with the key.
+ """
+ for key in self.keys():
+ yield (key, self[key])
+
def lists(self):
"""Returns a list of (key, list) pairs."""
return super(MultiValueDict, self).items()
diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py
index 62c57bc019..f5d5b91d3d 100644
--- a/tests/regressiontests/datastructures/tests.py
+++ b/tests/regressiontests/datastructures/tests.py
@@ -42,6 +42,8 @@ MergeDict can merge MultiValueDicts
'Simon'
>>> d.getlist('name')
['Adrian', 'Simon']
+>>> list(d.iteritems())
+[('position', 'Developer'), ('name', 'Simon')]
>>> d['lastname']
Traceback (most recent call last):
...