[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/securitypolicy/securitymap.py
Added a cache for the expensive getAllCells method.
Jim Fulton
jim at zope.com
Thu Jun 24 18:20:38 EDT 2004
Log message for revision 25976:
Added a cache for the expensive getAllCells method.
-=-
Modified: Zope3/trunk/src/zope/app/securitypolicy/securitymap.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/securitymap.py 2004-06-24 21:49:39 UTC (rev 25975)
+++ Zope3/trunk/src/zope/app/securitypolicy/securitymap.py 2004-06-24 22:20:38 UTC (rev 25976)
@@ -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