dabo Commit
Revision 6229
Date: 2010-11-30 15:23:25 -0800 (Tue, 30 Nov 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6229

Changed:
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
When using dynamic properties, if you need to call grid.getValue() to determine 
what dynamic value to return, you would hit an infinite loop. I added a 
parameter to the overridden GetValue() method to control this.

While looking through the above, I found that the dColumn._getColumnIndex() 
method was clumsy and inefficient, so I fixed that method, too.


Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2010-11-29 18:42:01 UTC (rev 6228)
+++ trunk/dabo/ui/uiwx/dGrid.py 2010-11-30 23:23:25 UTC (rev 6229)
@@ -295,7 +295,8 @@
 #              return False
 
 
-       def GetValue(self, row, col, useCache=True, convertNoneToString=True):
+       def GetValue(self, row, col, useCache=True, convertNoneToString=True,
+                       dynamicUpdate=True):
                col = self._convertWxColNumToDaboColNum(col)
                if useCache:
                        cv = self.__cachedVals.get((row, col))
@@ -307,8 +308,9 @@
                bizobj = self.grid.getBizobj()
                col_obj = self.grid.Columns[col]
                field = col_obj.DataField
-               col_obj._updateDynamicProps()
-               col_obj._updateCellDynamicProps(row)
+               if dynamicUpdate:
+                       col_obj._updateDynamicProps()
+                       col_obj._updateCellDynamicProps(row)
                if bizobj:
                        if field and (row < bizobj.RowCount):
                                ret = 
self.getStringValue(bizobj.getFieldVal(field, row))
@@ -720,17 +722,10 @@
 
        def _getColumnIndex(self):
                """Return our column index in the grid, or -1."""
-               gridCol = -1
                try:
-                       grid = self.Parent
+                       return self.Parent.Columns.index(self)
                except AttributeError:
-                       grid = None
-               if grid is not None:
-                       for idx, dCol in enumerate(grid.Columns):
-                               if dCol == self:
-                                       gridCol = idx
-                                       break
-               return gridCol
+                       return -1
 
 
        def _updateEditor(self):
@@ -1964,9 +1959,9 @@
                return ret
 
 
-       def GetValue(self, row, col):
+       def GetValue(self, row, col, dynamicUpdate=True):
                try:
-                       ret = self._Table.GetValue(row, col)
+                       ret = self._Table.GetValue(row, col, 
dynamicUpdate=dynamicUpdate)
                except AttributeError:
                        ret = super(dGrid, self).GetValue(row, col)
                return ret
@@ -2007,7 +2002,7 @@
                        row = self.CurrentRow
                if col is None:
                        col = self.CurrentColumn
-               ret = self.GetValue(row, col)
+               ret = self.GetValue(row, col, dynamicUpdate=False)
                if isinstance(ret, str):
                        ret = ret.decode(self.Encoding)
                return ret



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to