Permalink
Browse files

Fixed #7331 -- Made `QueryDict.iteritems` behave like `QueryDict.item…

…s`, thanks jurev.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent ddc156b commit 2b82a3bcfc757c2bdafca6c5d9930201deed00cf @gdub gdub committed Aug 16, 2008
Showing with 10 additions and 0 deletions.
  1. +8 −0 django/utils/datastructures.py
  2. +2 −0 tests/regressiontests/datastructures/tests.py
View
8 django/utils/datastructures.py
@@ -266,6 +266,14 @@ def items(self):
"""
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()
View
2 tests/regressiontests/datastructures/tests.py
@@ -42,6 +42,8 @@
'Simon'
>>> d.getlist('name')
['Adrian', 'Simon']
+>>> list(d.iteritems())
+[('position', 'Developer'), ('name', 'Simon')]
>>> d['lastname']
Traceback (most recent call last):
...

0 comments on commit 2b82a3b

Please sign in to comment.