[GRASS-SVN] r36422 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 19 08:13:27 EDT 2009


Author: martinl
Date: 2009-03-19 08:13:27 -0400 (Thu, 19 Mar 2009)
New Revision: 36422

Modified:
   grass/trunk/gui/wxpython/gui_modules/dbm.py
Log:
wxGUI: disable casting values for all platforms
      (merge from devbr6, r36420)


Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2009-03-19 12:12:49 UTC (rev 36421)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2009-03-19 12:13:27 UTC (rev 36422)
@@ -250,13 +250,15 @@
             j = 0
             
             for value in record.split('|'):
-                # casting ...
                 if self.columns[columns[j]]['ctype'] != type(''):
                     try:
-                        self.itemDataMap[i].append(self.columns[columns[j]]['ctype'] (value))
+                        ### casting disabled (2009/03)
+                        ### self.itemDataMap[i].append(self.columns[columns[j]]['ctype'](value))
+                        self.itemDataMap[i].append(value)
                     except ValueError:
-                        self.itemDataMap[i].append('')
+                        self.itemDataMap[i].append(_('Unknown value'))
                 else:
+                    # encode string values
                     try:
                         self.itemDataMap[i].append(unicodeValue(value))
                     except UnicodeDecodeError:
@@ -270,7 +272,7 @@
                         cat = -1
                         wx.MessageBox(parent=self,
                                       message=_("Error loading attribute data. "
-                                                "Record number: %(rec)d. Unable to cast value '%(val)s' in "
+                                                "Record number: %(rec)d. Unable to convert value '%(val)s' in "
                                                 "key column (%(key)s) to integer.\n\n"
                                                 "Details: %(detail)s") % \
                                           { 'rec' : i + 1, 'val' : value,
@@ -1256,9 +1258,15 @@
                             continue
 
                     try:
-                        values[i] = list.columns[columnName[i]]['ctype'] (values[i])
+                        if list.columns[columnName[i]]['ctype'] == int:
+                            # values[i] is stored as text. 
+                            value = float(values[i])
+                        else:
+                            value = values[i]
+                        values[i] = list.columns[columnName[i]]['ctype'] (value)
+
                     except:
-                        raise ValueError(_("Casting value '%(value)s' to %(type)s failed.") % 
+                        raise ValueError(_("Value '%(value)s' needs to be entered as %(type)s.") % 
                                          {'value' : str(values[i]),
                                           'type' : list.columns[columnName[i]]['type']})
                     columnsString += '%s,' % columnName[i]
@@ -1356,12 +1364,16 @@
                                 else:
                                     idx = i
                                 if list.columns[columnName[i]]['ctype'] != type(''):
+                                    if list.columns[columnName[i]]['ctype'] == int:
+                                        value = float(values[i])
+                                    else:
+                                        value = values[i]
                                     list.itemDataMap[item][idx] = \
-                                        list.columns[columnName[i]]['ctype'] (values[i])
+                                        list.columns[columnName[i]]['ctype'] (value)
                                 else:
                                     list.itemDataMap[item][idx] = values[i]
                             except:
-                                raise ValueError(_("Casting value '%(value)s' to %(type)s failed.") % \
+                                raise ValueError(_("Value '%(value)s' needs to be entered as %(type)s.") % \
                                                      {'value' : str(values[i]),
                                                       'type' : list.columns[columnName[i]]['type']})
 
@@ -1371,6 +1383,7 @@
                                 updateString += "%s=%s," % (columnName[i], values[i])
                         else: # NULL
                             updateString += "%s=NULL," % (columnName[i])
+                            
             except ValueError, err:
                 wx.MessageBox(parent=self,
                               message="%s%s%s" % (_("Unable to update existing record."),
@@ -1383,7 +1396,9 @@
                                                     (table, updateString.strip(','),
                                                      keyColumn, cat))
                 self.ApplyCommands()
-                
+
+            list.Update(self.mapDBInfo)
+                        
     def OnDataReload(self, event):
         """Reload list of records"""
         self.OnApplySqlStatement(None)



More information about the grass-commit mailing list