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

Kiran Jonnalagadda jace at pobox.com
Sat Jan 10 11:02:35 EST 2004


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

Modified Files:
	BTreeFolder2.py 
Log Message:
Added a manage_fixCount method to fix the self._count counter after recovery
from data corruption. I have a BTreeFolder2 instance here that says the count
is 14552 but actually has only 12861 items.


=== Products/BTreeFolder2/BTreeFolder2.py 1.18 => 1.19 ===
--- Products/BTreeFolder2/BTreeFolder2.py:1.18	Mon Dec 29 18:27:34 2003
+++ Products/BTreeFolder2/BTreeFolder2.py	Sat Jan 10 11:02:35 2004
@@ -107,6 +107,34 @@
                 self._setOb(name, aq_base(value))
 
 
+    security.declareProtected(view_management_screens,
+        'manage_fixCount')
+    def manage_fixCount(self):
+        """Calls self._fixCount() and reports the result as text.
+        """
+        old, new = self._fixCount()
+        path = '/'.join(self.getPhysicalPath())
+        if old==new:
+            return "No count mismatch detected in BTreeFolder2 at %s."\
+                % path
+        else:
+            return ("Fixed count mismatch in BTreeFolder2 at %s. "
+                    "Count was %d; corrected to %d" % (path, old, new))
+
+
+    def _fixCount(self):
+        """Checks if the value of self._count disagrees with
+        len(self.objectIds()). If so, corrects self._count. Returns the
+        old and new count values. If old==new, no correction was
+        performed.
+        """
+        old = self._count()
+        new = len(self.objectIds())
+        if old != new:
+            self._count.set(new)
+        return old, new
+
+
     security.declareProtected(view_management_screens, 'manage_cleanup')
     def manage_cleanup(self):
         """Calls self._cleanup() and reports the result as text.




More information about the Zope-CVS mailing list