[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/utils.py The set-item method of odict should be case-insensitive to allow dynamic attributes with different casing to take precedence over a static attribute of the same name (without respect to case).

Malthe Borch mborch at gmail.com
Tue Sep 2 09:25:39 EDT 2008


Log message for revision 90705:
  The set-item method of odict should be case-insensitive to allow dynamic attributes with different casing to take precedence over a static attribute of the same name (without respect to case).

Changed:
  U   z3c.pt/trunk/src/z3c/pt/utils.py

-=-
Modified: z3c.pt/trunk/src/z3c/pt/utils.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/utils.py	2008-09-02 13:24:18 UTC (rev 90704)
+++ z3c.pt/trunk/src/z3c/pt/utils.py	2008-09-02 13:25:38 UTC (rev 90705)
@@ -161,9 +161,15 @@
         self._keys.remove(key)
 
     def __setitem__(self, key, item):
+        """Case insensitive set item."""
+        
         UserDict.__setitem__(self, key, item)
-        if key in self._keys:
-            self._keys.remove(key)
+        keys = tuple(key.lower() for key in self._keys)
+        _key = key.lower()
+        if _key in keys:
+            for k in self._keys:
+                if k.lower() == _key:
+                    self._keys.remove(k)
         self._keys.append(key)
 
     def clear(self):



More information about the Checkins mailing list