Ticket #6465: 6465-1.diff

File 6465-1.diff, 1.3 KB (added by Matt McClanahan, 17 years ago)
  • django/utils/datastructures.py

     
    2525
    2626    def getlist(self, key):
    2727        for dict_ in self.dicts:
    28             try:
     28            if key in dict_.keys():
    2929                return dict_.getlist(key)
    30             except KeyError:
    31                 pass
    32         raise KeyError
     30        return []
    3331
    3432    def items(self):
    3533        item_list = []
  • tests/regressiontests/datastructures/tests.py

     
    2020>>> md2['chris']
    2121'cool'
    2222
     23MergeDict can merge MultiValueDicts
     24>>> multi1 = MultiValueDict({'key1': ['value1'], 'key2': ['value2', 'value3']})
     25>>> multi2 = MultiValueDict({'key3': ['value4'], 'key4': ['value5', 'value6']})
     26>>> mm = MergeDict(multi1, multi2)
     27>>> mm.getlist('key2')
     28['value2', 'value3']
     29>>> mm.getlist('key4')
     30['value5', 'value6']
     31>>> mm.getlist('undefined')
     32[]
     33
    2334### MultiValueDict ##########################################################
    2435
    2536>>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']})
Back to Top