Ticket #12820: mergedict_patch.diff
File mergedict_patch.diff, 1.3 KB (added by , 15 years ago) |
---|
-
django/utils/datastructures.py
1 import itertools 1 2 from types import GeneratorType 2 3 3 4 from django.utils.copycompat import deepcopy … … 37 38 return dict_.getlist(key) 38 39 return [] 39 40 41 def __iter__(self): 42 seen = set() 43 for key in itertools.chain.from_iterable(self.dicts): 44 if key not in seen: 45 seen.add(key) 46 yield key 47 40 48 def items(self): 41 49 item_list = [] 42 50 for dict_ in self.dicts: -
tests/regressiontests/datastructures/tests.py
34 34 >>> mm.getlist('undefined') 35 35 [] 36 36 37 MergeDict supports iterating on keys 38 >>> [(k,mm.getlist(k)) for k in mm] 39 [('key2', ['value2', 'value3']), ('key1', ['value1']), ('key4', ['value5', 'value6'])] 40 37 41 ### MultiValueDict ########################################################## 38 42 39 43 >>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']})