[Zope-Checkins] CVS: Zope3/lib/python/Interface - _Element.py:1.1.2.1.2.1 _InterfaceClass.py:1.1.2.2.2.1

Jim Fulton jim@zope.com
Mon, 25 Mar 2002 14:38:42 -0500


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

Modified Files:
      Tag: Zope3-publisher-refactor-branch
	_Element.py _InterfaceClass.py 
Log Message:
Fixed Attribute so that you no longer need to give a dang attribute
name as long as the doc has a space in it. :)

For example:

  class IFoo(Interface):

     spam = Attribute("The spam thingy")





=== Zope3/lib/python/Interface/_Element.py 1.1.2.1 => 1.1.2.1.2.1 ===
         """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.2.2.1 ===
         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)