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

Jim Fulton jim@zope.com
Tue, 26 Mar 2002 16:26:22 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	_Element.py _InterfaceClass.py pyskel.py 
Log Message:
Merged the publication refactoring branch into the main branch.

Also renamed:

  browser_reaverse -> publishTraverse

  browser_default -> browserDefault



=== Zope3/lib/python/Interface/_Element.py 1.1.2.2 => 1.1.2.3 ===
         """Create an 'attribute' description
         """
+        if not __doc__ and __name__.find(' ') >= 0:
+            __doc__ = __name__
+            __name__ = None
+        
         self.__name__=__name__
         self.__doc__=__doc__
 


=== Zope3/lib/python/Interface/_InterfaceClass.py 1.1.2.2 => 1.1.2.3 ===
         Element.__init__(self, name, __doc__)
 
-
-
         for k, v in attrs.items():
-            if isinstance(v, Method):
+            if isinstance(v, Attribute):
                 v.interface=name
-                v.__name__=k
+                if not v.__name__:
+                    v.__name__ = k
             elif isinstance(v, FunctionType):
                 attrs[k]=fromFunction(v, name)
-            elif not isinstance(v, Attribute):
+            else:
                 raise Exceptions.InvalidInterface(
                     "Concrete attribute, %s" % k)
 


=== Zope3/lib/python/Interface/pyskel.py 1.1.2.4 => 1.1.2.5 ===
 from Interface.Method import Method
 
-def rskel(iface):
-    name = iface.__name__
-    for base in iface.__bases__:
-        rskel(base)
+def rskel(iface, print_iface=1):
+    name = "%s.%s" % (iface.__module__, iface.__name__)
+
+    namesAndDescriptions = list(iface.namesAndDescriptions())
+
+    if namesAndDescriptions and print_iface:
+        print
+        print "    ######################################"
+        print "    # from:", name
 
-    for aname, ades in iface.namesAndDescriptions():
+    # XXX it would be better to keep the original order, but interfaces don't
+    # preserve this, so we'll just sort for now.
+    namesAndDescriptions.sort() 
+    for aname, ades in namesAndDescriptions:
         if isinstance(ades, Method):
             sig = ades.getSignatureString()[1:-1]
             if sig: sig = "self, %s" % sig
             else:   sig = "self"
             print
             print "    def %s(%s):" % (aname, sig)
-            print "        '''See interface %s'''" % name
+            print "        'See %s'" % name
+
+    for base in iface.__bases__:
+        rskel(base)
 
 def skel(name):
     iface = resolve(name)
@@ -59,7 +70,7 @@
     print "    # Implementation methods for interface"
     print "    #", name
 
-    rskel(iface)
+    rskel(iface, 0)
 
     print "    #"
     print "    ############################################################"