[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/securitymap.py Merged from trunk 25976:

Jim Fulton jim at zope.com
Fri Jul 2 16:50:11 EDT 2004


Log message for revision 26070:
Merged from trunk 25976:
Added a cache for the expensive getAllCells method.



-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/securitymap.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/securitymap.py	2004-07-02 20:47:15 UTC (rev 26069)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/securitymap.py	2004-07-02 20:50:11 UTC (rev 26070)
@@ -40,12 +40,20 @@
 
         col = self._bycol.setdefault(colentry, self._empty_mapping())
         col[rowentry] = value
+        try:
+            del self._v_cells
+        except AttributeError:
+            pass
 
     def delCell(self, rowentry, colentry):
         row = self._byrow.get(rowentry)
         if row and (colentry in row):
             del self._byrow[rowentry][colentry]
             del self._bycol[colentry][rowentry]
+        try:
+            del self._v_cells
+        except AttributeError:
+            pass
 
     def getCell(self, rowentry, colentry, default=None):
         " return the value of a cell by row, entry "
@@ -69,10 +77,15 @@
 
     def getAllCells(self):
         " return a list of (rowentry, colentry, value) "
+        try:
+            return self._v_cells
+        except AttributeError:
+            pass
         res = []
         for r in self._byrow.keys():
             for c in self._byrow[r].items():
                 res.append((r,) + c)
+        self._v_cells = res
         return res
 
 



More information about the Zope3-Checkins mailing list