Skip to content

Commit

Permalink
Fixed #7331 -- Made QueryDict.iteritems behave like `QueryDict.item…
Browse files Browse the repository at this point in the history
…s`, thanks jurev.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
gdub committed Aug 16, 2008
1 parent ddc156b commit 2b82a3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions django/utils/datastructures.py
Expand Up @@ -266,6 +266,14 @@ def items(self):
""" """
return [(key, self[key]) for key in self.keys()] 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): def lists(self):
"""Returns a list of (key, list) pairs.""" """Returns a list of (key, list) pairs."""
return super(MultiValueDict, self).items() return super(MultiValueDict, self).items()
Expand Down
2 changes: 2 additions & 0 deletions tests/regressiontests/datastructures/tests.py
Expand Up @@ -42,6 +42,8 @@
'Simon' 'Simon'
>>> d.getlist('name') >>> d.getlist('name')
['Adrian', 'Simon'] ['Adrian', 'Simon']
>>> list(d.iteritems())
[('position', 'Developer'), ('name', 'Simon')]
>>> d['lastname'] >>> d['lastname']
Traceback (most recent call last): Traceback (most recent call last):
... ...
Expand Down

0 comments on commit 2b82a3b

Please sign in to comment.