[Zope-Checkins] CVS: Zope/lib/python/Interface/Common - Mapping.py:1.1.4.1 __init__.py:1.1.4.1

Jim Fulton jim@zope.com
Fri, 7 Jun 2002 13:08:57 -0400


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

Added Files:
      Tag: Zope3InterfaceBackport-branch
	Mapping.py __init__.py 
Log Message:
Backported Zope 3 Interface package to Python 2.1 with or without
ExtensionClass. 

If ExtensionClass is present, then Interfaces are ExtensionClass
instances that pickle as global variables (like classes
do). Otherwise, interfaces will usually not be picklable.

There are a couple of enhancements (like queryDefinition) that now
need to be forward ported to Zope 3 Interfaces.

This package should *only* be used for Python 2.1. For Python 2.2 and
higher, use the Zope 3 interface package.



=== Added File Zope/lib/python/Interface/Common/Mapping.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: Mapping.py,v 1.1.4.1 2002/06/07 17:08:56 jim Exp $
"""

from Interface import Interface

class IReadMapping(Interface):
    """Basic mapping interface
    """

    def __getitem__(key):
        """Get a value for a key

        A KeyError is raised if there is no value for the key.
        """

    def get(key, default=None):
        """Get a value for a key

        The default is returned if there is no value for the key.
        """

    def has_key(key):
        """Tell if a key exists in the mapping
        """

class IEnumerableMapping(IReadMapping):
    """Mapping objects whose items can be enumerated
    """

    def keys():
        """Return the keys of the mapping object
        """

    def values():
        """Return the values of the mapping object
        """

    def items():
        """Return the items of the mapping object
        """

    def __len__():
        """Return the number of items
        """


=== Added File Zope/lib/python/Interface/Common/__init__.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.
# 
##############################################################################