[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Memento - AttributeMementoBag.py:1.1.2.1 IAttributeMementoStorable.py:1.1.2.1 IMementoBag.py:1.1.2.1 __init__.py:1.1.2.1

R. David Murray rdmurray@bitdance.com
Sat, 23 Mar 2002 13:03:28 -0500


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

Added Files:
      Tag: Zope-3x-branch
	AttributeMementoBag.py IAttributeMementoStorable.py 
	IMementoBag.py __init__.py 
Log Message:
Implementation of AttributeMementoBag from Tres Sever's proposal at
ComponentArchitecture/MementoBagProposal, as modified by Jim's comments
about the use of dotted names rather than a key registry.

R. David Murray (rdmurray) and Nikheel Dhekne (ndhekne).


=== Added File Zope3/lib/python/Zope/App/OFS/Memento/AttributeMementoBag.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: AttributeMementoBag.py,v 1.1.2.1 2002/03/23 18:03:27 rdmurray Exp $
"""

from Persistence.BTrees.OOBTree import OOBTree

class AttributeMementoBag:

    """
    Store memento bag data in the __membag__ attribute on a
    IAttributeMementoStorable object.
    """

    def __init__(self,obj):
        if not hasattr(obj,'__memobag__'): obj.__memobag__ = OOBTree()
        self.obj = obj

    def __getattr__(self,attr):
        return getattr(self.obj.__memobag__,attr)


=== Added File Zope3/lib/python/Zope/App/OFS/Memento/IAttributeMementoStorable.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: IAttributeMementoStorable.py,v 1.1.2.1 2002/03/23 18:03:27 rdmurray Exp $
"""
from Interface import Interface

class IAttributeMementoStorable(Interface):
    """
    Marker interfaces giving permission for an IMementoBag adapter to store
    data in an an attribute named __memobag__.
    """


=== Added File Zope3/lib/python/Zope/App/OFS/Memento/IMementoBag.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: IMementoBag.py,v 1.1.2.1 2002/03/23 18:03:27 rdmurray Exp $
"""
from Interface import Interface

class IMementoBag(Interface):
    """
    MementoBags store arbitrary application data under package unique keys
    """

    def __getitem__(key):
        """
        Return the memento stored under key.

        Raises KeyError if key not found.
        """

    def get(key, default=None):
        """
        Return the memento stored under key, returning default if not found.
        """

    def __setitem__(key, memento):
        """
        Store memento under key.

        In order to avoid key collisions, users of this interface must
        use their dotted package name as part of the key name.
        """

    def __delitem__(key):
        """
        Removes the memento stored under key.

        Raises a KeyError if the key is not found.
        """


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