[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container - BTreeContainer.py:1.1.2.1 SampleContainer.py:1.1.2.2

Jim Fulton jim@zope.com
Mon, 4 Mar 2002 12:42:35 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	SampleContainer.py 
Added Files:
      Tag: Zope-3x-branch
	BTreeContainer.py 
Log Message:
Oops. The class (formerly known as Container) in
Zope.App.OFS.Container.SampleContainer isn't really useful for
production use directly, because it doesn;t follow the rules of
persistence. 

Added a BTreeContainer that is suitable.

Changes ServiceManager to use it.
 


=== Added File Zope3/lib/python/Zope/App/OFS/Container/BTreeContainer.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
# 
##############################################################################
"""
This module provides a sample container implementation.

This is primarily for testing purposes.

It might be useful as a mix-in for some classes, but many classes will
need a very different implementation.

Revision information:
$Id: BTreeContainer.py,v 1.1.2.1 2002/03/04 17:42:04 jim Exp $
"""

from Persistence import Persistent
from Persistence.BTrees.OOBTree import OOBTree
from Zope.App.OFS.Container.SampleContainer import SampleContainer

class BTreeContainer(SampleContainer, Persistent):

    __implements__ =  SampleContainer.__implements__, Persistent.__implements__

    def _Container__newData(self):
        """Construct an item-data container

        Subclasses should override this if they want different data.

        The value returned is a mapping object that also has get,
        has_key, keys, items, and values methods.
        """
        return OOBTree()


=== Zope3/lib/python/Zope/App/OFS/Container/SampleContainer.py 1.1.2.1 => 1.1.2.2 ===
 _marker = object()
 
-class Container(object):
+class SampleContainer(object):
+    """Sample container implementation suitable for testing.
+
+    It is not suitable, directly as a base class unless the subclass
+    overrides _Container__newData to return a persistent mapping
+    object.
+    """
 
     __implements__ =  IContainer