Ticket #8447: iterlists.diff
File iterlists.diff, 2.1 KB (added by , 16 years ago) |
---|
-
django/utils/datastructures.py
278 278 """Returns a list of (key, list) pairs.""" 279 279 return super(MultiValueDict, self).items() 280 280 281 def iterlists(self): 282 """Yields (key, list) pairs.""" 283 return super(MultiValueDict, self).iteritems() 284 281 285 def values(self): 282 286 """Returns a list of the last value on every key list.""" 283 287 return [self[key] for key in self.keys()] -
tests/regressiontests/datastructures/tests.py
44 44 ['Adrian', 'Simon'] 45 45 >>> list(d.iteritems()) 46 46 [('position', 'Developer'), ('name', 'Simon')] 47 >>> list(d.iterlists()) 48 [('position', 'Developer'), ('name', ['Adrian', 'Simon'])] 47 49 >>> d['lastname'] 48 50 Traceback (most recent call last): 49 51 ... -
docs/request_response.txt
278 278 >>> q = QueryDict('a=1&a=2&a=3') 279 279 >>> q.items() 280 280 [('a', '3')] 281 282 * ``iteritems()`` -- Just like the standard dictionary ``iteritems()`` 283 method. Like ``items()`` this uses the same last-value logic as 284 ``__getitem()__``. 281 285 282 286 * ``values()`` -- Just like the standard dictionary ``values()`` method, 283 287 except this uses the same last-value logic as ``__getitem()__``. For … … 312 316 >>> q = QueryDict('a=1&a=2&a=3') 313 317 >>> q.lists() 314 318 [('a', ['1', '2', '3'])] 319 320 * ''iterlists()'' -- Like ''iteritems()'', except it includes all values, 321 as a list, for each member of the dictionary. 315 322 316 323 * ``urlencode()`` -- Returns a string of the data in query-string format. 317 324 Example: ``"a=2&b=3&b=5"``.