[Checkins] SVN: z3c.table/trunk/ Bugfix:

Roger Ineichen roger at projekt01.ch
Fri Oct 10 18:41:25 EDT 2008


Log message for revision 92029:
  Bugfix:
  CheckBoxColumn, ensure that we allways use a list for compare 
  selected items. It was possible that if only one item get selected 
  we compared a string. If this string was a sub string of another 
  existing item the other item get selected too.

Changed:
  U   z3c.table/trunk/CHANGES.txt
  U   z3c.table/trunk/src/z3c/table/column.py

-=-
Modified: z3c.table/trunk/CHANGES.txt
===================================================================
--- z3c.table/trunk/CHANGES.txt	2008-10-10 21:18:46 UTC (rev 92028)
+++ z3c.table/trunk/CHANGES.txt	2008-10-10 22:41:24 UTC (rev 92029)
@@ -5,6 +5,11 @@
 Version 0.5.1dev (unreleased)
 -----------------------------
 
+- Bugfix: CheckBoxColumn, ensure that we allways use a list for compare
+  selected items. It was possible that if only one item get selected
+  we compared a string. If this string was a sub string of another existing
+  item the other item get selected too.
+
 - Fixed advanced batching implementation, and extracted it in a separate
   function
 

Modified: z3c.table/trunk/src/z3c/table/column.py
===================================================================
--- z3c.table/trunk/src/z3c/table/column.py	2008-10-10 21:18:46 UTC (rev 92028)
+++ z3c.table/trunk/src/z3c/table/column.py	2008-10-10 22:41:24 UTC (rev 92029)
@@ -201,10 +201,18 @@
     def getItemValue(self, item):
         return api.getName(item)
 
+    def isSelected(self, item):
+        v = self.request.get(self.getItemKey(item), [])
+        if not isinstance(v, list):
+            # ensure that we have a list which prevents to compare strings
+            v = [v]
+        if self.getItemValue(item) in v:
+            return True
+        return False
+
     def update(self):
         self.selectedItems = [item for item in self.table.values
-                              if self.getItemValue(item)
-                              in self.request.get(self.getItemKey(item), [])]
+                              if self.isSelected(item)]
 
     def renderCell(self, item):
         selected = u''



More information about the Checkins mailing list