Log message for revision 30156:
added BTreeFolder2
Changed:
A Zope/trunk/lib/python/Products/BTreeFolder2/
A Zope/trunk/lib/python/Products/BTreeFolder2/BTreeFolder2.py
A Zope/trunk/lib/python/Products/BTreeFolder2/BTreeFolder2.pyc
A Zope/trunk/lib/python/Products/BTreeFolder2/CHANGES.txt
A Zope/trunk/lib/python/Products/BTreeFolder2/CMFBTreeFolder.py
A Zope/trunk/lib/python/Products/BTreeFolder2/README.txt
A Zope/trunk/lib/python/Products/BTreeFolder2/__init__.py
A Zope/trunk/lib/python/Products/BTreeFolder2/__init__.pyc
A Zope/trunk/lib/python/Products/BTreeFolder2/btreefolder2.gif
A Zope/trunk/lib/python/Products/BTreeFolder2/contents.dtml
A Zope/trunk/lib/python/Products/BTreeFolder2/folderAdd.dtml
A Zope/trunk/lib/python/Products/BTreeFolder2/tests/
A Zope/trunk/lib/python/Products/BTreeFolder2/tests/__init__.py
A Zope/trunk/lib/python/Products/BTreeFolder2/tests/__init__.pyc
A Zope/trunk/lib/python/Products/BTreeFolder2/tests/testBTreeFolder2.py
A Zope/trunk/lib/python/Products/BTreeFolder2/tests/testBTreeFolder2.pyc
A Zope/trunk/lib/python/Products/BTreeFolder2/version.txt
-=-
Added: Zope/trunk/lib/python/Products/BTreeFolder2/BTreeFolder2.py
===
--- Zope/trunk/lib/python/Products/BTreeFolder2/BTreeFolder2.py 2005-04-25
10:01:22 UTC (rev 30155)
+++ Zope/trunk/lib/python/Products/BTreeFolder2/BTreeFolder2.py 2005-04-25
13:29:39 UTC (rev 30156)
@@ -0,0 +1,514 @@
+##
+#
+# 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
+#
+##
+"""BTreeFolder2
+
+$Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $
+"""
+
+import sys
+from cgi import escape
+from urllib import quote
+from random import randint
+from types import StringType
+
+import Globals
+from Globals import DTMLFile
+from Globals import Persistent
+from Acquisition import aq_base
+from BTrees.OOBTree import OOBTree
+from BTrees.OIBTree import OIBTree, union
+from BTrees.Length import Length
+from ZODB.POSException import ConflictError
+from OFS.ObjectManager import BadRequestException, BeforeDeleteException
+from OFS.Folder import Folder
+from AccessControl import getSecurityManager, ClassSecurityInfo
+from AccessControl.Permissions import access_contents_information, \
+ view_management_screens
+from zLOG import LOG, INFO, ERROR, WARNING
+from Products.ZCatalog.Lazy import LazyMap
+
+
+manage_addBTreeFolderForm = DTMLFile('folderAdd', globals())
+
+def manage_addBTreeFolder(dispatcher, id, title='', REQUEST=None):
+"""Adds a new BTreeFolder object with id *id*.
+"""
+id = str(id)
+ob = BTreeFolder2(id)
+ob.title = str(title)
+dispatcher._setObject(id, ob)
+ob = dispatcher._getOb(id)
+if REQUEST is not None:
+return dispatcher.manage_main(dispatcher, REQUEST, update_menu=1)
+
+
+listtext0 = '''
+'''
+listtext1 = '''%s
+'''
+listtext2 = '''
+'''
+
+
+_marker = [] # Create a new marker object.
+
+MAX_UNIQUEID_ATTEMPTS = 1000
+
+class ExhaustedUniqueIdsError (Exception):
+pass
+
+
+class BTreeFolder2Base (Persistent):
+"""Base for BTree-based folders.
+"""
+
+security = ClassSecurityInfo()
+
+manage_options=(
+({'label':'Contents', 'action':'manage_main',},
+ ) + Folder.manage_options[1:]
+)
+
+security.declareProtected(view_management_screens,
+ 'manage_main')
+manage_main = DTMLFile('contents', globals())
+
+_tree = None # OOBTree: { id -> object }
+_count = None # A BTrees.Length
+_v_nextid = 0 # The integer component of the next generated ID
+_mt_index = None # OOBTree: { meta_type -> OIBTree: { id -> 1 } }
+title = ''
+
+
+def __init__(self, id=None):
+if id is not None:
+self.id = id
+self._initBTrees()
+
+def _initBTrees(self):
+self._tree = OOBTree()
+self._count = Length()
+self._mt_index = OOBTree()
+
+
+def _populateFromFolder(self, source):
+"""Fill this folder with the contents of another folder.
+"""
+for name in source.objectIds():
+value = source._getOb(name, None)
+if value is not None:
+self._setOb(name, aq_base(value))
+
+
+security.declareProtected(view_management_screens, 'manage_fixCount')
+def manage_fixCount(se