[Zope-CVS] CVS: Products/BTreeFolder2 - BTreeFolder2.py:1.9

Shane Hathaway shane@cvs.zope.org
Thu, 6 Jun 2002 14:05:36 -0400


Update of /cvs-repository/Products/BTreeFolder2
In directory cvs.zope.org:/tmp/cvs-serv14725

Modified Files:
	BTreeFolder2.py 
Log Message:
Added docstrings and cleaned up generateId() slightly.


=== Products/BTreeFolder2/BTreeFolder2.py 1.8 => 1.9 ===
 
     def _populateFromFolder(self, source):
+        """Fill this folder with the contents of another folder.
+        """
         ids = source.objectIds()
         tree = self._tree
         count = self._count
@@ -121,6 +123,8 @@
 
 
     def _getOb(self, id, default=_marker):
+        """Return the named object from the folder.
+        """
         tree = self._tree
         if default is _marker:
             ob = tree[id]
@@ -134,7 +138,7 @@
 
 
     def _setOb(self, id, object):
-        """Stores the object in the BTree.
+        """Store the named object in the folder.
         """
         tree = self._tree
         if tree.has_key(id):
@@ -153,6 +157,8 @@
 
 
     def _delOb(self, id):
+        """Remove the named object from the folder.
+        """
         tree = self._tree
         meta_type = getattr(tree[id], 'meta_type', None)
         del tree[id]
@@ -171,6 +177,8 @@
 
     security.declareProtected(view_management_screens, 'getBatchObjectListing')
     def getBatchObjectListing(self, REQUEST=None):
+        """Return a structure for a page template to show the list of objects.
+        """
         if REQUEST is None:
             REQUEST = {}
         pref_rows = int(REQUEST.get('dtpref_rows', 20))
@@ -384,11 +392,11 @@
         tree = self._tree
         n = self._v_nextid
         while 1:
-            id = '%s%d%s' % (prefix, n, suffix)
-            if n % 4000 == 0 or tree.has_key(id):
-                n = randint(1, 999999999)
-            else:
-                break
+            if n % 4000 != 0:
+                id = '%s%d%s' % (prefix, n, suffix)
+                if not tree.has_key(id):
+                    break
+            n = randint(1, 999999999)
         self._v_nextid = n + 1
         return id