Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed several hardcoding of `dict` method calls in `django.utils.da…

…tastructures.py` to use `super` instead.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 303d22b0d29eff19c9a68eb98a50ef336eaaeb2d 1 parent 8df3d2b
Gary Wilson Jr. authored

Showing 1 changed file with 20 additions and 19 deletions. Show diff stats Hide diff stats

  1. 39  django/utils/datastructures.py
39  django/utils/datastructures.py
@@ -56,7 +56,7 @@ class SortedDict(dict):
56 56
     def __init__(self, data=None):
57 57
         if data is None:
58 58
             data = {}
59  
-        dict.__init__(self, data)
  59
+        super(SortedDict, self).__init__(data)
60 60
         if isinstance(data, dict):
61 61
             self.keyOrder = data.keys()
62 62
         else:
@@ -68,12 +68,12 @@ def __deepcopy__(self, memo):
68 68
                                for key, value in self.iteritems()])
69 69
 
70 70
     def __setitem__(self, key, value):
71  
-        dict.__setitem__(self, key, value)
  71
+        super(SortedDict, self).__setitem__(key, value)
72 72
         if key not in self.keyOrder:
73 73
             self.keyOrder.append(key)
74 74
 
75 75
     def __delitem__(self, key):
76  
-        dict.__delitem__(self, key)
  76
+        super(SortedDict, self).__delitem__(key)
77 77
         self.keyOrder.remove(key)
78 78
 
79 79
     def __iter__(self):
@@ -81,7 +81,7 @@ def __iter__(self):
81 81
             yield k
82 82
 
83 83
     def pop(self, k, *args):
84  
-        result = dict.pop(self, k, *args)
  84
+        result = super(SortedDict, self).pop(k, *args)
85 85
         try:
86 86
             self.keyOrder.remove(k)
87 87
         except ValueError:
@@ -90,7 +90,7 @@ def pop(self, k, *args):
90 90
         return result
91 91
 
92 92
     def popitem(self):
93  
-        result = dict.popitem(self)
  93
+        result = super(SortedDict, self).popitem()
94 94
         self.keyOrder.remove(result[0])
95 95
         return result
96 96
 
@@ -99,7 +99,7 @@ def items(self):
99 99
 
100 100
     def iteritems(self):
101 101
         for key in self.keyOrder:
102  
-            yield key, dict.__getitem__(self, key)
  102
+            yield key, super(SortedDict, self).__getitem__(key)
103 103
 
104 104
     def keys(self):
105 105
         return self.keyOrder[:]
@@ -108,11 +108,11 @@ def iterkeys(self):
108 108
         return iter(self.keyOrder)
109 109
 
110 110
     def values(self):
111  
-        return [dict.__getitem__(self, k) for k in self.keyOrder]
  111
+        return [super(SortedDict, self).__getitem__(k) for k in self.keyOrder]
112 112
 
113 113
     def itervalues(self):
114 114
         for key in self.keyOrder:
115  
-            yield dict.__getitem__(self, key)
  115
+            yield super(SortedDict, self).__getitem__(key)
116 116
 
117 117
     def update(self, dict_):
118 118
         for k, v in dict_.items():
@@ -121,7 +121,7 @@ def update(self, dict_):
121 121
     def setdefault(self, key, default):
122 122
         if key not in self.keyOrder:
123 123
             self.keyOrder.append(key)
124  
-        return dict.setdefault(self, key, default)
  124
+        return super(SortedDict, self).setdefault(key, default)
125 125
 
126 126
     def value_for_index(self, index):
127 127
         """Returns the value of the item at the given zero-based index."""
@@ -135,7 +135,7 @@ def insert(self, index, key, value):
135 135
             if n < index:
136 136
                 index -= 1
137 137
         self.keyOrder.insert(index, key)
138  
-        dict.__setitem__(self, key, value)
  138
+        super(SortedDict, self).__setitem__(key, value)
139 139
 
140 140
     def copy(self):
141 141
         """Returns a copy of this object."""
@@ -173,10 +173,11 @@ class MultiValueDict(dict):
173 173
     single name-value pairs.
174 174
     """
175 175
     def __init__(self, key_to_list_mapping=()):
176  
-        dict.__init__(self, key_to_list_mapping)
  176
+        super(MultiValueDict, self).__init__(key_to_list_mapping)
177 177
 
178 178
     def __repr__(self):
179  
-        return "<%s: %s>" % (self.__class__.__name__, dict.__repr__(self))
  179
+        return "<%s: %s>" % (self.__class__.__name__,
  180
+                             super(MultiValueDict, self).__repr__())
180 181
 
181 182
     def __getitem__(self, key):
182 183
         """
@@ -184,7 +185,7 @@ def __getitem__(self, key):
184 185
         raises KeyError if not found.
185 186
         """
186 187
         try:
187  
-            list_ = dict.__getitem__(self, key)
  188
+            list_ = super(MultiValueDict, self).__getitem__(key)
188 189
         except KeyError:
189 190
             raise MultiValueDictKeyError, "Key %r not found in %r" % (key, self)
190 191
         try:
@@ -193,10 +194,10 @@ def __getitem__(self, key):
193 194
             return []
194 195
 
195 196
     def __setitem__(self, key, value):
196  
-        dict.__setitem__(self, key, [value])
  197
+        super(MultiValueDict, self).__setitem__(key, [value])
197 198
 
198 199
     def __copy__(self):
199  
-        return self.__class__(dict.items(self))
  200
+        return self.__class__(super(MultiValueDict, self).items())
200 201
 
201 202
     def __deepcopy__(self, memo=None):
202 203
         import copy
@@ -222,12 +223,12 @@ def get(self, key, default=None):
222 223
     def getlist(self, key):
223 224
         """Returns an empty list if the requested data doesn't exist."""
224 225
         try:
225  
-            return dict.__getitem__(self, key)
  226
+            return super(MultiValueDict, self).__getitem__(key)
226 227
         except KeyError:
227 228
             return []
228 229
 
229 230
     def setlist(self, key, list_):
230  
-        dict.__setitem__(self, key, list_)
  231
+        super(MultiValueDict, self).__setitem__(key, list_)
231 232
 
232 233
     def setdefault(self, key, default=None):
233 234
         if key not in self:
@@ -242,7 +243,7 @@ def setlistdefault(self, key, default_list=()):
242 243
     def appendlist(self, key, value):
243 244
         """Appends an item to the internal list associated with key."""
244 245
         self.setlistdefault(key, [])
245  
-        dict.__setitem__(self, key, self.getlist(key) + [value])
  246
+        super(MultiValueDict, self).__setitem__(key, self.getlist(key) + [value])
246 247
 
247 248
     def items(self):
248 249
         """
@@ -253,7 +254,7 @@ def items(self):
253 254
 
254 255
     def lists(self):
255 256
         """Returns a list of (key, list) pairs."""
256  
-        return dict.items(self)
  257
+        return super(MultiValueDict, self).items()
257 258
 
258 259
     def values(self):
259 260
         """Returns a list of the last value on every key list."""

0 notes on commit 303d22b

Please sign in to comment.
Something went wrong with that request. Please try again.