[Zodb-checkins] CVS: Packages/ZConfig - datatypes.py:1.9

Fred L. Drake, Jr. fred@zope.com
Mon, 20 Jan 2003 18:11:18 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv19107

Modified Files:
	datatypes.py 
Log Message:
Fix problem with datatype case sensitivity, reported by Guido.
This makes the registry itself smarter, which is probably the best place for
it; apps that replace the registry can decide for themselves how "smart"
the lookup should be.


=== Packages/ZConfig/datatypes.py 1.8 => 1.9 ===
--- Packages/ZConfig/datatypes.py:1.8	Thu Jan 16 20:58:52 2003
+++ Packages/ZConfig/datatypes.py	Mon Jan 20 18:10:44 2003
@@ -313,15 +313,24 @@
 
 class Registry:
     __metatype__ = type
-    __slots__ = '_stock', '_other'
+    __slots__ = '_stock', '_other', '_basic_key'
 
     def __init__(self, stock=None):
         if stock is None:
             stock = stock_datatypes.copy()
         self._stock = stock
         self._other = {}
+        self._basic_key = None
 
     def get(self, name):
+        if '.' not in name:
+            if self._basic_key is None:
+                self._basic_key = self._other.get("basic-key")
+                if self._basic_key is None:
+                    self._basic_key = self._stock.get("basic-key")
+                if self._basic_key is None:
+                    self._basic_key = stock_datatypes["basic-key"]
+            name = self._basic_key(name)
         t = self._stock.get(name)
         if t is None:
             t = self._other.get(name)