[Zope-Checkins] CVS: Zope3/lib/python/Interface - IInterface.py:1.1.2.3 _InterfaceClass.py:1.1.2.5

Jim Fulton jim@zope.com
Fri, 7 Jun 2002 14:00:15 -0400


Update of /cvs-repository/Zope3/lib/python/Interface
In directory cvs.zope.org:/tmp/cvs-serv2585/lib/python/Interface

Modified Files:
      Tag: Zope-3x-branch
	IInterface.py _InterfaceClass.py 
Log Message:
Split the Interface getDescription method into getDescription and
queryDescription methods, according to the new get/query method
convention. 


=== Zope3/lib/python/Interface/IInterface.py 1.1.2.2 => 1.1.2.3 ===
         """
 
-    def getDescriptionFor(name, default=None):
+    def getDescriptionFor(name):
         """Get the description for a name
 
-        If no default is sepecified and the named attribute does not
-        exist, a KeyError is raised.
+        If the named attribute does not exist, a KeyError is raised.
+
+        """
+
+    def queryDescriptionFor(name, default=None):
+        """Look up the description for a name
+
+        If the named attribute does not exist, the default is
+        returned.
+
         """


=== Zope3/lib/python/Interface/_InterfaceClass.py 1.1.2.4 => 1.1.2.5 ===
 from _Element import Element
 
-_marker = object()
-
 class Interface(Element):
     """Prototype (scarecrow) Interfaces Implementation
     """
@@ -153,21 +151,27 @@
 
         return r.items()
 
-    def getDescriptionFor(self, name, default=_marker):
+    def getDescriptionFor(self, name):
+        """Return the attribute description for the given name
+        """
+        r = self.queryDescriptionFor(name)
+        if r is not None:
+            return r
+        
+        raise KeyError, name
+
+    def queryDescriptionFor(self, name, default=None):
         """Return the attribute description for the given name
         """
         r = self.__attrs.get(name, self)
         if r is not self:
             return r
         for base in self.__bases__:
-            r = base.getDescriptionFor(name, self)
+            r = base.queryDescriptionFor(name, self)
             if r is not self:
                 return r
             
-        if default is not _marker:
-            return default
-
-        raise KeyError, name
+        return default
 
     def deferred(self):
         """Return a defered class corresponding to the interface