[Zope3-checkins] CVS: Zope3/src/zope/interface - implementor.py:1.2.12.1

Jim Fulton jim@zope.com
Thu, 13 Mar 2003 14:32:13 -0500


Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv8865

Modified Files:
      Tag: local-utility-branch
	implementor.py 
Log Message:
Checking into branch

=== Zope3/src/zope/interface/implementor.py 1.2 => 1.2.12.1 ===
--- Zope3/src/zope/interface/implementor.py:1.2	Wed Dec 25 09:13:42 2002
+++ Zope3/src/zope/interface/implementor.py	Thu Mar 13 14:32:12 2003
@@ -36,8 +36,10 @@
     # Where the registered provides is what was registered and
     # provided may be some base interface
 
-    def __init__(self):
-        self._reg = {}
+    def __init__(self, data=None):
+        if data is None:
+            data = {}
+        self._reg = data
 
     def _registerAllProvided(self, primary_provide, object, provide):
         # Registers a component using (require, provide) as a key.
@@ -70,12 +72,24 @@
 
         self._registerAllProvided(provide, object, provide)
 
-    def get(self, provide, default=None):
+    def gerRegistered(self, interface, default=None):
+        """Find the component registered exactly for the interface
         """
-        Finds a registered component that provides the given interface.
-        Returns None if not found.
+        c = self._reg.get(interface)
+        if c is not None and c[0] is interface:
+            return c[1]
+
+        return default
+        
+
+    def get(self, interface, default=None):
+        """Find the component registered for the interface
+
+        A component may be returned if it was registered fgor a more
+        specific interface.
+        
         """
-        c = self._reg.get(provide)
+        c = self._reg.get(interface)
         if c is not None:
             return c[1]