[GRASS-SVN] r36421 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 19 08:12:49 EDT 2009


Author: martinl
Date: 2009-03-19 08:12:49 -0400 (Thu, 19 Mar 2009)
New Revision: 36421

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


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm.py	2009-03-19 11:48:57 UTC (rev 36420)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm.py	2009-03-19 12:12:49 UTC (rev 36421)
@@ -248,13 +248,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:
@@ -268,7 +270,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,
@@ -1238,9 +1240,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]
@@ -1338,12 +1346,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']})
 
@@ -1353,6 +1365,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."),
@@ -1365,7 +1378,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