[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - SecurityMap.py:1.1.2.2
Jim Fulton
jim@zope.com
Thu, 3 Jan 2002 14:09:47 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv13005
Modified Files:
Tag: Zope-3x-branch
SecurityMap.py
Log Message:
Added deletion method to support "retract" in subclasses.
Added checking for duplicates.
=== Zope3/lib/python/Zope/App/Security/SecurityMap.py 1.1.2.1 => 1.1.2.2 ===
self._clear()
+ def delCell(self, rowentry, colentry):
+ row = self._byrow.get(rowentry, ())
+ if colentry in row:
+ row.remove(colentry)
+
+ col = self._bycol.get(colentry, ())
+ if rowentry in col:
+ col.remove(rowentry)
+
def addCell(self, rowentry, colentry):
"""Add a cell to the table."""
- self._byrow.setdefault(rowentry, []).append(colentry)
- self._bycol.setdefault(colentry, []).append(rowentry)
+ row = self._byrow.get(rowentry)
+ if row is None:
+ self._byrow[rowentry] = [colentry]
+ else:
+ if colentry not in row:
+ row.append(colentry)
+
+ col = self._bycol.get(colentry)
+ if col is None:
+ self._bycol[colentry] = [rowentry]
+ else:
+ if rowentry not in col:
+ col.append(rowentry)
def getColumnsForRow(self, rowentry):
"""Return a list of column entries for a given row entry.