[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/PropertySets - IPropertySet.py:1.1.2.1 IPropertySetDef.py:1.1.2.1 PropertySetDef.py:1.1.2.1 __init__.py:1.1.2.1

R. David Murray rdmurray@bitdance.com
Fri, 29 Mar 2002 20:42:53 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/PropertySets
In directory cvs.zope.org:/tmp/cvs-serv985/PropertySets

Added Files:
      Tag: Zope-3x-branch
	IPropertySet.py IPropertySetDef.py PropertySetDef.py 
	__init__.py 
Log Message:
Initial checkin of PropertySet work done at the NY sprint by
R. David Murray and Nikheel Dhekne.  PropertySetDef is more
or less working, and the Interface for PropertySet is defined.
This code is actually a little behind the recent changes
to the use case/example.


=== Added File Zope3/lib/python/Zope/App/OFS/PropertySets/IPropertySet.py ===
##############################################################################
#
# Copyright (c) 2001 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
#
##############################################################################
"""

$Id: IPropertySet.py,v 1.1.2.1 2002/03/30 01:42:52 rdmurray Exp $"
"""
from Interface import Interface

class IPropertySet(Interface):

    """
    Interface to access a collection of properties
    """

    def __getitem__(name):
        """
        Return the value associated with the property
        """

    def __setitem__(name, value):
        """
        Store the value for the property.
        """

    def getField(name):
        """
        Get the IField that defines the property 'name'.
        """

    def has_field(name):
        """
        True if the PropertySet has the property name
        """

    def fieldNames():
        """
        Returns a list of the names of the properties
        """

    def __iter__():
        """
        Returns an iterator over the names of the properties
        """

    def __len__():
        """
        Returns the number of properties in the PropertySet
        """


=== Added File Zope3/lib/python/Zope/App/OFS/PropertySets/IPropertySetDef.py ===
##############################################################################
#
# Copyright (c) 2001 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
#
##############################################################################
"""

$Id: IPropertySetDef.py,v 1.1.2.1 2002/03/30 01:42:52 rdmurray Exp $"
"""
from Interface import Interface

class IPropertySetDef(Interface):

    """
    Interface to manage a collection of properties
    """

    def __init__():
        """
        Create an empty PropertySetDef
        """

    def addField(name,field):
        """
        Add a IField object to the PropertySet under name 'name'.
        """

    def getField(name):
        """
        Return the IField defining the property 'name'.
        """

    def has_field(name):
        """
        True if the PropertySet has a property named 'name'.
        """

    def fieldNames():
        """
        Returns a list of the property names defined by the PropertySet
        """

    def __iter__():
        """
        Returns an iterator over the IFields
        """

    def __len__():
        """
        Returns the number of fields in the PropertySetDef
        """


=== Added File Zope3/lib/python/Zope/App/OFS/PropertySets/PropertySetDef.py ===
from Zope.App.OFS.PropertySets.IPropertySetDef import IPropertySetDef
from Zope.Exceptions import DuplicationError

class PropertySetDef:

    __implements__ =  IPropertySetDef

    ############################################################
    # Implementation methods for interface
    # Zope.App.OFS.PropertySets.IPropertySetDef.

    def __init__(self):
        '''See interface IPropertySetDef'''
        self.fields = {}
        self.namelist = []

    def has_field(self, name):
        '''See interface IPropertySetDef'''
        return self.fields.has_key(name)

    def addField(self, name, field):
        '''See interface IPropertySetDef'''
        if self.fields.has_key(name): raise DuplicationError(name)
        self.fields[name] = field
        self.namelist.append(name)

    def getField(self, name):
        '''See interface IPropertySetDef'''
        return self.fields[name]

    def fieldNames(self):
        '''See interface IPropertySetDef'''
        return self.namelist

    def __len__(self):
        '''See interface IPropertySetDef'''
        return len(self.namelist)

    def __iter__(self):
        '''See interface IPropertySetDef'''
        return iter([ self.fields[x] for x in self.namelist ])

    #
    ############################################################


=== Added File Zope3/lib/python/Zope/App/OFS/PropertySets/__init__.py ===