diff options
| author | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-09 17:43:46 +0000 |
|---|---|---|
| committer | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-09 17:43:46 +0000 |
| commit | 0b7dd14d1f87e2ecef7aacc39fe4189667ed4fdf (patch) | |
| tree | b77497f9de324d38a9c6341e54d2742633e20055 /django/utils/datastructures.py | |
| parent | e17f75551491f5b864c1fc8a97c21d0b2bbf0bcd (diff) | |
boulder-oracle-sprint: Merged to trunk [4692].
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4695 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/datastructures.py')
| -rw-r--r-- | django/utils/datastructures.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 9bec7a5df7..e924e4edbc 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -16,8 +16,11 @@ class MergeDict(object): def __contains__(self, key): return self.has_key(key) + + def __copy__(self): + return self.__class__(*self.dicts) - def get(self, key, default): + def get(self, key, default=None): try: return self[key] except KeyError: @@ -42,6 +45,10 @@ class MergeDict(object): if dict.has_key(key): return True return False + + def copy(self): + """ returns a copy of this object""" + return self.__copy__() class SortedDict(dict): "A dictionary that keeps its keys in the order in which they're inserted." @@ -85,6 +92,13 @@ class SortedDict(dict): "Returns the value of the item at the given zero-based index." return self[self.keyOrder[index]] + def copy(self): + "Returns a copy of this object." + # This way of initialising the copy means it works for subclasses, too. + obj = self.__class__(self) + obj.keyOrder = self.keyOrder + return obj + class MultiValueDictKeyError(KeyError): pass |
