[Zope-Checkins] CVS: Zope/lib/python/Interface - _Attribute.py:1.1 IElement.py:1.3 Method.py:1.10 _Interface.py:1.3 _InterfaceClass.py:1.3 __init__.py:1.7 pyskel.py:1.3 Attribute.py:NONE iclass.py:NONE

Chris McDonough chrism@zope.com
Mon, 10 Jun 2002 12:47:39 -0400


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

Modified Files:
	IElement.py Method.py _Interface.py _InterfaceClass.py 
	__init__.py pyskel.py 
Added Files:
	_Attribute.py 
Removed Files:
	Attribute.py iclass.py 
Log Message:
For "old" Interface packages b/w compatibility:

  Because the "old" Interface package allowed the import of the Attribute
  class directly from the Interface package, and some packages
  (such as CMF) expect a class back from "from Interface import Attribute":

  - Renamed Attribute.py to _Attribute.py and did the necessary
    housekeeping to make sure all the other parts of the Interface
    package knows about the change.

  - Changed __init__.py to import Attribute from _Attribute

New features and changes:

  - Removed iclass.py  (it was no longer used).

  - Gave the base interface class (Interface._InterfaceClass) a __hash__
    method as ExtensionClass instances do not hash like normal
    instances, and we require that interfaces be hashable in order to
    store them as dictionary keys and whatnot in registries.
  


=== Added File Zope/lib/python/Interface/_Attribute.py ===
##############################################################################
#
# 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: _Attribute.py,v 1.1 2002/06/10 16:47:38 chrism Exp $
"""

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




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


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


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


=== Zope/lib/python/Interface/_InterfaceClass.py 1.2 => 1.3 ===
 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
@@ -212,6 +212,12 @@
 
     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


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


=== Zope/lib/python/Interface/pyskel.py 1.2 => 1.3 ===
 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_]*)')

=== Removed File Zope/lib/python/Interface/Attribute.py ===

=== Removed File Zope/lib/python/Interface/iclass.py ===