[Zope-Checkins] CVS: Zope3/lib/python/Interface - Attribute.py:1.4 Document.py:1.3 Exceptions.py:1.9 IAttribute.py:1.3 IElement.py:1.4 IInterface.py:1.3 IMethod.py:1.3 Implements.py:1.3 Method.py:1.11 Verify.py:1.3 _Element.py:1.3 _Interface.py:1.4 _InterfaceClass.py:1.5 __init__.py:1.8 pyskel.py:1.4 Mapping.py:NONE _Attribute.py:NONE _object.py:NONE pprint.py:NONE

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:41 -0400


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

Modified Files:
	Document.py Exceptions.py IAttribute.py IElement.py 
	IInterface.py IMethod.py Implements.py Method.py Verify.py 
	_Element.py _Interface.py _InterfaceClass.py __init__.py 
	pyskel.py 
Added Files:
	Attribute.py 
Removed Files:
	Mapping.py _Attribute.py _object.py pprint.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Interface/Attribute.py 1.3 => 1.4 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from _Element import Element
+
+class Attribute(Element):
+    """Attribute descriptions
+    """
+
+    # We can't say this yet because we don't have enough
+    # infrastructure in place.
+    #
+    #__implements__ = IAttribute
+
+


=== Zope3/lib/python/Interface/Document.py 1.2 => 1.3 ===
         level = level - 1
 
-    namesAndDescriptions = list(I.namesAndDescriptions())
-    namesAndDescriptions.sort()
-
-
     outp(_justify_and_indent("Attributes:", level, munge)+'\n\n')
     level = level + 1
-    for name, desc in namesAndDescriptions:
+    for name, desc in I.namesAndDescriptions():
         if not hasattr(desc, 'getSignatureString'):   # ugh...
             item = "%s -- %s" % (desc.getName(),
                                  desc.getDoc() or 'no documentation')
@@ -60,7 +56,7 @@
 
     outp(_justify_and_indent("Methods:", level, munge)+'\n\n')
     level = level + 1
-    for name, desc in namesAndDescriptions:
+    for name, desc in I.namesAndDescriptions():
         if hasattr(desc, 'getSignatureString'):   # ugh...
             item = "%s%s -- %s" % (desc.getName(),
                                    desc.getSignatureString(),


=== Zope3/lib/python/Interface/Exceptions.py 1.8 => 1.9 ===
 
     def __str__(self):
-        return """The implementation of %(method)s violates its contract
+        return """The implementation of %(method)s violates it's contract
         because %(mess)s.
         """ % self.__dict__
 


=== Zope3/lib/python/Interface/IAttribute.py 1.2 => 1.3 ===


=== Zope3/lib/python/Interface/IElement.py 1.3 => 1.4 ===
 
 from _Interface import Interface
-from _Attribute import Attribute
+from Attribute import Attribute
 
 class IElement(Interface):
     """Objects that have basic documentation and tagged values.


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


=== Zope3/lib/python/Interface/IMethod.py 1.2 => 1.3 ===


=== Zope3/lib/python/Interface/Implements.py 1.2 => 1.3 ===
 CLASS_INTERFACES = 1
 
-from _object import ClassTypes, isInstance
+ClassTypes = (ClassType, type(object))
 
 _typeImplements={}
 
@@ -64,7 +64,7 @@
     implements_class = getattr(implements, '__class__', None)
     
     if implements_class == InterfaceClass or \
-       isInstance(implements, InterfaceClass):
+       isinstance(implements, InterfaceClass):
         return visitor(implements)
     elif implements == CLASS_INTERFACES:
         klass = getattr(object, '__class__', None)
@@ -140,7 +140,7 @@
         index = len(res) - 1
         while index >= 0:
             i = res[index]
-            if seen.has_key(i):
+            if i in seen:
                 del res[index]
             else:
                 seen[i] = 1


=== Zope3/lib/python/Interface/Method.py 1.10 => 1.11 ===
 """
 import Exceptions
-from _Attribute import Attribute
+from Attribute import Attribute
 
 sig_traits = ['positional', 'required', 'optional', 'varargs', 'kwargs']
 


=== Zope3/lib/python/Interface/Verify.py 1.2 => 1.3 ===
 from Exceptions import BrokenImplementation, DoesNotImplement
 from Exceptions import BrokenMethodImplementation
-from types import FunctionType
+from types import FunctionType, MethodType
 from Method import fromMethod, fromFunction
-from _object import MethodTypes
 
 def _verify(iface, candidate, tentative=0, vtype=None):
     """
@@ -52,7 +51,7 @@
         if type(attr) is FunctionType:
             # should never get here
             meth = fromFunction(attr, n)
-        elif type(attr) in MethodTypes:
+        elif type(attr) is MethodType:
             meth = fromMethod(attr, n)
         else:
             continue # must be an attribute...


=== Zope3/lib/python/Interface/_Element.py 1.2 => 1.3 ===
 """
 
-from _object import object
-
 class Element(object):
 
     # We can't say this yet because we don't have enough


=== Zope3/lib/python/Interface/_Interface.py 1.3 => 1.4 ===
     from Implements import implements
 
-    from _Attribute import Attribute
+    from Attribute import Attribute
     from IAttribute import IAttribute
     implements(Attribute, IAttribute)
 


=== Zope3/lib/python/Interface/_InterfaceClass.py 1.4 => 1.5 ===
 import sys
 from Method import Method, fromFunction
-from _Attribute import Attribute
+from Attribute import Attribute
 from types import FunctionType
 import Exceptions
 from _Element import Element
-from _object import isInstance
 
 class Interface(Element):
     """Prototype (scarecrow) Interfaces Implementation
@@ -39,7 +38,7 @@
                  __module__=None):
         
         if __module__ is None:
-            if attrs is not None and attrs.has_key('__module__'):
+            if attrs is not None and ('__module__' in attrs):
                 __module__ = attrs['__module__']
                 del attrs['__module__']
             else:
@@ -53,12 +52,12 @@
         self.__module__ = __module__
 
         for b in bases:
-            if not isInstance(b, Interface):
+            if not isinstance(b, Interface):
                 raise TypeError, 'Expected base interfaces'
         self.__bases__=bases
 
         if attrs is None: attrs={}
-        if attrs.has_key('__doc__'):
+        if '__doc__' in attrs:
             if __doc__ is None: __doc__=attrs['__doc__']
             del attrs['__doc__']
 
@@ -70,7 +69,7 @@
         Element.__init__(self, name, __doc__)
 
         for k, v in attrs.items():
-            if isInstance(v, Attribute):
+            if isinstance(v, Attribute):
                 v.interface=name
                 if not v.__name__:
                     v.__name__ = k
@@ -147,7 +146,7 @@
             
         for base in self.__bases__:
             for name, d in base.namesAndDescriptions(all):
-                if not r.has_key(name):
+                if name not in r:
                     r[name] = d
 
         return r.items()
@@ -198,7 +197,7 @@
     def __d(self, dict):
 
         for k, v in self.__attrs.items():
-            if isInstance(v, Method) and not dict.has_key(k):
+            if isinstance(v, Method) and not (k in dict):
                 dict[k]=v
 
         for b in self.__bases__: b.__d(dict)
@@ -212,12 +211,6 @@
 
     def __reduce__(self):
         return self.__name__
-
-    def __hash__(self):
-        """ interface instances need to be hashable, and inheriting
-        from extensionclass makes instances unhashable unless we declare
-        a __hash__ method here"""
-        return id(self)
 
 # We import this here to deal with module dependencies.
 from Implements import getImplementsOfInstances, visitImplements, getImplements


=== Zope3/lib/python/Interface/__init__.py 1.7 => 1.8 ===
 
 from _Interface import Interface
-from _Attribute import Attribute
 Base = Interface # XXX We need to stamp out Base usage
 


=== Zope3/lib/python/Interface/pyskel.py 1.3 => 1.4 ===
 sys.path.insert(0, os.getcwd())
 
-from _object import isInstance
-
 from types import ModuleType
 from Interface.Method import Method
-from Interface._Attribute import Attribute
+from Interface.Attribute import Attribute
 
 class_re = re.compile(r'\s*class\s+([a-zA-Z_][a-zA-Z0-9_]*)')
 def_re = re.compile(r'\s*def\s+([a-zA-Z_][a-zA-Z0-9_]*)')
@@ -58,7 +56,7 @@
         print "    # from:", name
 
     for aname, ades in namesAndDescriptions:
-        if isInstance(ades, Method):
+        if isinstance(ades, Method):
             sig = ades.getSignatureString()[1:-1]
             if sig: sig = "self, %s" % sig
             else:   sig = "self"
@@ -66,7 +64,7 @@
             print "    def %s(%s):" % (aname, sig)
             print "        'See %s'" % name
 
-        elif isInstance(ades, Attribute):
+        elif isinstance(ades, Attribute):
             print
             print "    # See %s" % name
             print "    %s = None" %aname

=== Removed File Zope3/lib/python/Interface/Mapping.py ===

=== Removed File Zope3/lib/python/Interface/_Attribute.py ===

=== Removed File Zope3/lib/python/Interface/_object.py ===

=== Removed File Zope3/lib/python/Interface/pprint.py ===