Commits

Anonymous committed a3d2299

fixes for headerdict

  • Participants
  • Parent commits d0b5fb5

Comments (0)

Files changed (1)

webob/headerdict.py

         return str(key).lower().strip()
 
     def __getitem__(self, key):
-        key = self.normalize(key)
+        normalize = self.normalize
+        key = normalize(key)
         for k, v in reversed(self._items):
-            if self.normalize(k) == key:
+            if normalize(k) == key:
                 return v
         raise KeyError(key)
 
     def getall(self, key):
-        key = self.normalize(key)
+        normalize = self.normalize
+        key = normalize(key)
         result = []
         for k, v in self._items:
-            if self.normalize(k) == key:
+            if normalize(k) == key:
                 result.append(v)
         return result
 
-    def add(self, key, value):
-        key = self.normalize(key)
-        if key in self:
-            if isinstance(self[key], list):
-                self[key].append(value)
-            else:
-                self[key] = [self[key], value]
-        else:
-            self[key] = value
-
-    def mized(self):
+    def mixed(self):
         result = {}
         multi = {}
+        normalize = self.normalize
         for key, value in self.iteritems():
-            key = self.normalize(key)
+            key = normalize(key)
             if key in result:
                 if key in multi:
                     result[key].append(value)
 
     def dict_of_lists(self):
         result = {}
+        normalize = self.normalize
         for key, value in self.iteritems():
-            key = self.normalize(key)
+            key = normalize(key)
             if key in result:
                 result[key].append(value)
             else:
         return result
 
     def __delitem__(self, key):
-        key = self.normalize(key)
+        normalize = self.normalize
+        key = normalize(key)
         items = self._items
         found = False
         for i in range(len(items)-1, -1, -1):
-            if self.normalize(items[i][0]) == key:
+            if normalize(items[i][0]) == key:
                 del items[i]
                 found = True
         if not found:
             raise KeyError(key)
 
     def __contains__(self, key):
-        key = self.normalize(key)
+        normalize = self.normalize
+        key = normalize(key)
         for k, v in self._items:
-            if self.normalize(k) == key:
+            if normalize(k) == key:
                 return True
         return False
 
     has_key = __contains__
 
     def setdefault(self, key, default=None):
-        c_key = self.normalize(key)
+        normalize = self.normalize
+        c_key = normalize(key)
         for k, v in self._items:
-            if self.normalize(k) == c_key:
+            if normalize(k) == c_key:
                 return v
         self._items.append((key, default))
         return default
             return args[0]
         else:
             raise KeyError(key)
+