diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-03 02:02:41 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-03 02:02:41 +0000 |
| commit | 2542b94fb214847af0a4e1eca84558debbf32ee2 (patch) | |
| tree | 468947f006dcb4bb44d5a23b1c85e2308dab79c1 /django | |
| parent | f467c8cbc133bd4300961226ccced499fb8a485e (diff) | |
Fixed #6465 -- Tweaked MergeDict.getlist() to work with Django's MultiValueDict class. Thanks, Matt McClanahan.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7062 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/datastructures.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 25e9421575..82d914000f 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -2,6 +2,9 @@ class MergeDict(object): """ A simple class for creating new "virtual" dictionaries that actually look up values in more than one dictionary, passed in the constructor. + + If a key appears in more than one of the passed in dictionaries, only the + first occurrence will be used. """ def __init__(self, *dicts): self.dicts = dicts @@ -25,11 +28,9 @@ class MergeDict(object): def getlist(self, key): for dict_ in self.dicts: - try: + if key in dict_.keys(): return dict_.getlist(key) - except KeyError: - pass - raise KeyError + return [] def items(self): item_list = [] |
