~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/utils/datastructures.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
            dict.__setitem__(result, copy.deepcopy(key, memo),
223
223
                             copy.deepcopy(value, memo))
224
224
        return result
225
 
 
 
225
    
 
226
    def __getstate__(self):
 
227
        obj_dict = self.__dict__.copy()
 
228
        obj_dict['_data'] = dict([(k, self.getlist(k)) for k in self])
 
229
        return obj_dict
 
230
    
 
231
    def __setstate__(self, obj_dict):
 
232
        data = obj_dict.pop('_data', {})
 
233
        for k, v in data.items():
 
234
            self.setlist(k, v)
 
235
        self.__dict__.update(obj_dict)
 
236
        
226
237
    def get(self, key, default=None):
227
238
        """
228
239
        Returns the last data value for the passed key. If key doesn't exist
283
294
        """Returns a list of (key, list) pairs."""
284
295
        return super(MultiValueDict, self).items()
285
296
 
 
297
    def iterlists(self):
 
298
        """Yields (key, list) pairs."""
 
299
        return super(MultiValueDict, self).iteritems()
 
300
 
286
301
    def values(self):
287
302
        """Returns a list of the last value on every key list."""
288
303
        return [self[key] for key in self.keys()]
289
 
 
 
304
        
 
305
    def itervalues(self):
 
306
        """Yield the last value on every key list."""
 
307
        for key in self.iterkeys():
 
308
            yield self[key]
 
309
    
290
310
    def copy(self):
291
311
        """Returns a copy of this object."""
292
312
        return self.__deepcopy__()