[Checkins] SVN: Products.BTreeFolder2/trunk/ Cleanup

Hanno Schlichting hannosch at hannosch.eu
Sun Jul 11 08:14:36 EDT 2010


Log message for revision 114583:
  Cleanup
  

Changed:
  U   Products.BTreeFolder2/trunk/README.txt
  U   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py
  D   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/CHANGES.txt
  D   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/README.txt
  U   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/__init__.py
  U   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/__init__.py
  U   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py
  D   Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/version.txt

-=-
Modified: Products.BTreeFolder2/trunk/README.txt
===================================================================
--- Products.BTreeFolder2/trunk/README.txt	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/README.txt	2010-07-11 12:14:35 UTC (rev 114583)
@@ -1,3 +1,79 @@
 Overview
 ========
 
+BTreeFolder2 is a Zope product that acts like a Zope 2 OFS folder but can
+store many more items.
+
+When you fill a Zope folder with too many items, both Zope and your
+browser get overwhelmed.  Zope has to load and store a large folder
+object, and the browser has to render large HTML tables repeatedly.
+Zope can store a lot of objects, but it has trouble storing a lot of
+objects in a single standard folder.
+
+Zope Corporation once had an extensive discussion on the subject.  It
+was decided that we would expand standard folders to handle large
+numbers of objects gracefully.  Unfortunately, Zope folders are used
+and extended in so many ways today that it would be difficult to
+modify standard folders in a way that would be compatible with all
+Zope products.
+
+So the BTreeFolder product was born.  It stored all subobjects in a
+ZODB BTree, a structure designed to allow many items without loading
+them all into memory.  It also rendered the contents of the folder as
+a simple select list rather than a table.  Most browsers have no
+trouble rendering large select lists.
+
+But there was still one issue remaining.  BTreeFolders still stored
+the ID of all subobjects in a single database record.  If you put tens
+of thousands of items in a single BTreeFolder, you would still be
+loading and storing a multi-megabyte folder object.  Zope can do this,
+but not quickly, and not without bloating the database.
+
+BTreeFolder2 solves this issue.  It stores not only the subobjects but
+also the IDs of the subobjects in a BTree.  It also batches the list
+of items in the UI, showing only 1000 items at a time.  So if you
+write your application carefully, you can use a BTreeFolder2 to store
+as many items as will fit in physical storage.
+
+There are products that depend on the internal structure of the
+original BTreeFolder, however.  So rather than risk breaking those
+products, the product has been renamed.  You can have both products
+installed at the same time.  If you're developing new applications,
+you should use BTreeFolder2.
+
+
+Usage
+=====
+
+The BTreeFolder2 user interface shows a list of items rather than a
+series of checkboxes. To visit an item, select it in the list and
+click the "edit" button.
+
+BTreeFolder2 objects provide Python dictionary-like methods to make them
+easier to use in Python code than standard folders::
+
+    has_key(key)
+    keys()
+    values()
+    items()
+    get(key, default=None)
+    __len__()
+
+keys(), values(), and items() return sequences, but not necessarily
+tuples or lists.  Use len(folder) to call the __len__() method.  The
+objects returned by values() and items() have acquisition wrappers.
+
+BTreeFolder2 also provides a method for generating unique,
+non-overlapping IDs::
+
+    generateId(prefix='item', suffix='', rand_ceiling=999999999)
+
+The ID returned by this method is guaranteed to not clash with any
+other ID in the folder.  Use the returned value as the ID for new
+objects.  The generated IDs tend to be sequential so that objects that
+are likely related in some way get loaded together.
+
+BTreeFolder2 implements the full Folder interface, with the exception
+that the superValues() method does not return any items.  To implement
+the method in the way the Zope codebase expects would undermine the
+performance benefits gained by using BTreeFolder2.

Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py	2010-07-11 12:14:35 UTC (rev 114583)
@@ -12,8 +12,6 @@
 #
 ##############################################################################
 """BTreeFolder2
-
-$Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $
 """
 
 from cgi import escape
@@ -37,11 +35,9 @@
 from OFS.event import ObjectWillBeRemovedEvent
 from OFS.Folder import Folder
 from OFS.ObjectManager import BadRequestException
-from OFS.ObjectManager import BeforeDeleteException
 from OFS.subscribers import compatibilityCall
 from Persistence import Persistent
 from Products.ZCatalog.Lazy import LazyMap
-from ZODB.POSException import ConflictError
 from zope.event import notify
 from zope.lifecycleevent import ObjectAddedEvent
 from zope.lifecycleevent import ObjectRemovedEvent
@@ -52,6 +48,7 @@
 
 manage_addBTreeFolderForm = DTMLFile('folderAdd', globals())
 
+
 def manage_addBTreeFolder(dispatcher, id, title='', REQUEST=None):
     """Adds a new BTreeFolder object with id *id*.
     """
@@ -71,11 +68,11 @@
 listtext2 = '''</select>
 '''
 
-
 _marker = []  # Create a new marker object.
 
 MAX_UNIQUEID_ATTEMPTS = 1000
 
+
 class ExhaustedUniqueIdsError (Exception):
     pass
 
@@ -87,12 +84,11 @@
     security = ClassSecurityInfo()
 
     manage_options=(
-        ({'label':'Contents', 'action':'manage_main',},
+        ({'label': 'Contents', 'action': 'manage_main'},
          ) + Folder.manage_options[1:]
         )
 
-    security.declareProtected(view_management_screens,
-                              'manage_main')
+    security.declareProtected(view_management_screens, 'manage_main')
     manage_main = DTMLFile('contents', globals())
 
     _tree = None      # OOBTree: { id -> object }
@@ -411,8 +407,8 @@
 
     def _checkId(self, id, allow_dup=0):
         if not allow_dup and self.has_key(id):
-            raise BadRequestException, ('The id "%s" is invalid--'
-                                        'it is already in use.' % id)
+            raise BadRequestException('The id "%s" is invalid--'
+                                      'it is already in use.' % id)
 
 
     def _setObject(self, id, object, roles=None, user=None, set_owner=1,
@@ -517,7 +513,7 @@
         # Oh well.
         res = self._tree.get(name)
         if res is None:
-            raise AttributeError, name
+            raise AttributeError(name)
         return res
 
 
@@ -532,7 +528,6 @@
     def _checkId(self, id, allow_dup=0):
         Folder._checkId(self, id, allow_dup)
         BTreeFolder2Base._checkId(self, id, allow_dup)
-    
 
-InitializeClass(BTreeFolder2)
 
+InitializeClass(BTreeFolder2)

Deleted: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/CHANGES.txt
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/CHANGES.txt	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/CHANGES.txt	2010-07-11 12:14:35 UTC (rev 114583)
@@ -1,25 +0,0 @@
-Version 1.0.2
-
-  - Made CMFBTreeFolder compatible with CMF 1.5+
-
-Version 1.0.1
-
-  - ConflictError was swallowed by _delObject. This could break code
-    expecting to do cleanups before deletion.
-
-  - Renamed hasObject() to has_key().  hasObject() conflicted with
-    another product.
-
-  - You can now visit objects whose names have a trailing space.
-
-Version 1.0
-
-  - BTreeFolder2s now use an icon contributed by Chris Withers.
-
-  - Since recent ZODB releases have caused minor corruption in BTrees,
-    there is now a manage_cleanup method for fixing damaged BTrees
-    contained in BTreeFolders.
-
-Version 0.5.1
-
-  - Fixed the CMFBTreeFolder constructor.

Deleted: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/README.txt
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/README.txt	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/README.txt	2010-07-11 12:14:35 UTC (rev 114583)
@@ -1,114 +0,0 @@
-
-Contact
-=======
-
-Shane Hathaway
-Zope Corporation
-shane at zope dot com
-
-
-BTreeFolder2 Product
-====================
-
-BTreeFolder2 is a Zope product that acts like a Zope folder but can
-store many more items.
-
-When you fill a Zope folder with too many items, both Zope and your
-browser get overwhelmed.  Zope has to load and store a large folder
-object, and the browser has to render large HTML tables repeatedly.
-Zope can store a lot of objects, but it has trouble storing a lot of
-objects in a single standard folder.
-
-Zope Corporation once had an extensive discussion on the subject.  It
-was decided that we would expand standard folders to handle large
-numbers of objects gracefully.  Unfortunately, Zope folders are used
-and extended in so many ways today that it would be difficult to
-modify standard folders in a way that would be compatible with all
-Zope products.
-
-So the BTreeFolder product was born.  It stored all subobjects in a
-ZODB BTree, a structure designed to allow many items without loading
-them all into memory.  It also rendered the contents of the folder as
-a simple select list rather than a table.  Most browsers have no
-trouble rendering large select lists.
-
-But there was still one issue remaining.  BTreeFolders still stored
-the ID of all subobjects in a single database record.  If you put tens
-of thousands of items in a single BTreeFolder, you would still be
-loading and storing a multi-megabyte folder object.  Zope can do this,
-but not quickly, and not without bloating the database.
-
-BTreeFolder2 solves this issue.  It stores not only the subobjects but
-also the IDs of the subobjects in a BTree.  It also batches the list
-of items in the UI, showing only 1000 items at a time.  So if you
-write your application carefully, you can use a BTreeFolder2 to store
-as many items as will fit in physical storage.
-
-There are products that depend on the internal structure of the
-original BTreeFolder, however.  So rather than risk breaking those
-products, the product has been renamed.  You can have both products
-installed at the same time.  If you're developing new applications,
-you should use BTreeFolder2.
-
-
-Installation
-============
-
-Untar BTreeFolder2 in your Products directory and restart Zope.
-BTreeFolder2 will now be available in your "Add" drop-down.
-
-Additionally, if you have CMF installed, the BTreeFolder2 product also
-provides the "CMF BTree Folder" addable type.
-
-
-Usage
-=====
-
-The BTreeFolder2 user interface shows a list of items rather than a
-series of checkboxes.  To visit an item, select it in the list and
-click the "edit" button.
-
-BTreeFolder2 objects provide Python dictionary-like methods to make them
-easier to use in Python code than standard folders::
-
-    has_key(key)
-    keys()
-    values()
-    items()
-    get(key, default=None)
-    __len__()
-
-keys(), values(), and items() return sequences, but not necessarily
-tuples or lists.  Use len(folder) to call the __len__() method.  The
-objects returned by values() and items() have acquisition wrappers.
-
-BTreeFolder2 also provides a method for generating unique,
-non-overlapping IDs::
-
-    generateId(prefix='item', suffix='', rand_ceiling=999999999)
-
-The ID returned by this method is guaranteed to not clash with any
-other ID in the folder.  Use the returned value as the ID for new
-objects.  The generated IDs tend to be sequential so that objects that
-are likely related in some way get loaded together.
-
-BTreeFolder2 implements the full Folder interface, with the exception
-that the superValues() method does not return any items.  To implement
-the method in the way the Zope codebase expects would undermine the
-performance benefits gained by using BTreeFolder2.
-
-
-Repairing BTree Damage
-======================
-
-Certain ZODB bugs in the past have caused minor corruption in BTrees.
-Fortunately, the damage is apparently easy to repair.  As of version
-1.0, BTreeFolder2 provides a 'manage_cleanup' method that will check
-the internal structure of existing BTreeFolder2 instances and repair
-them if necessary.  Many thanks to Tim Peters, who fixed the BTrees
-code and provided a function for checking a BTree.
-
-Visit a BTreeFolder2 instance through the web as a manager.  Add
-"manage_cleanup" to the end of the URL and request that URL.  It may
-take some time to load and fix the entire structure.  If problems are
-detected, information will be added to the event log.

Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/__init__.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/__init__.py	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/__init__.py	2010-07-11 12:14:35 UTC (rev 114583)
@@ -11,9 +11,6 @@
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-__doc__='''BTreeFolder2 Product Initialization
-$Id: __init__.py,v 1.4 2003/08/21 17:03:52 shane Exp $'''
-__version__='$Revision: 1.4 $'[11:-2]
 
 import BTreeFolder2
 

Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/__init__.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/__init__.py	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/__init__.py	2010-07-11 12:14:35 UTC (rev 114583)
@@ -1 +1 @@
-"""Python package."""
+#
\ No newline at end of file

Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py	2010-07-11 12:14:35 UTC (rev 114583)
@@ -12,21 +12,18 @@
 #
 ##############################################################################
 """Unit tests for BTreeFolder2.
-
-$Id: testBTreeFolder2.py,v 1.8 2004/03/15 20:31:40 shane Exp $
 """
 
 import unittest
-import ZODB
-import Testing
-import Zope2
-from Products.BTreeFolder2.BTreeFolder2 \
-     import BTreeFolder2, ExhaustedUniqueIdsError
+
 from OFS.ObjectManager import BadRequestException
 from OFS.Folder import Folder
 from Acquisition import aq_base
 
+from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
+from Products.BTreeFolder2.BTreeFolder2 import ExhaustedUniqueIdsError
 
+
 class BTreeFolder2Tests(unittest.TestCase):
 
     def getBase(self, ob):
@@ -65,7 +62,7 @@
         mt1 = self.ff.meta_type
         mt2 = Folder.meta_type
         self.assertEqual(list(self.f.objectIds(mt1)), ['item'])
-        self.assertEqual(list(self.f.objectIds((mt1,))), ['item'])
+        self.assertEqual(list(self.f.objectIds((mt1, ))), ['item'])
         self.assertEqual(list(self.f.objectIds(mt2)), ['subfolder'])
         lst = list(self.f.objectIds([mt1, mt2]))
         lst.sort()
@@ -90,7 +87,7 @@
 
     def testHasKey(self):
         self.assert_(self.f.hasObject('item'))  # Old spelling
-        self.assert_(self.f.has_key('item'))  # New spelling
+        self.assert_('item' in self.f)  # New spelling
 
     def testDelete(self):
         self.f._delOb('item')
@@ -116,7 +113,7 @@
     def testSetObject(self):
         f2 = BTreeFolder2('item2')
         self.f._setObject(f2.id, f2)
-        self.assert_(self.f.has_key('item2'))
+        self.assert_('item2' in self.f)
         self.assertEqual(self.f.objectCount(), 2)
 
     def testWrapped(self):
@@ -151,7 +148,7 @@
         old_f._setObject(inner_f.id, inner_f)
         self.ff._populateFromFolder(old_f)
         self.assertEqual(self.ff.objectCount(), 1)
-        self.assert_(self.ff.has_key('inner'))
+        self.assert_('inner' in self.ff)
         self.assertEqual(self.getBase(self.ff._getOb('inner')), inner_f)
 
     def testObjectListing(self):
@@ -232,6 +229,3 @@
     return unittest.TestSuite((
         unittest.makeSuite(BTreeFolder2Tests),
         ))
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

Deleted: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/version.txt
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/version.txt	2010-07-11 12:07:36 UTC (rev 114582)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/version.txt	2010-07-11 12:14:35 UTC (rev 114583)
@@ -1 +0,0 @@
-BTreeFolder2-1.0.2



More information about the checkins mailing list