[GRASS-SVN] r61897 - grass/trunk/gui/wxpython/dbmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 13 10:07:10 PDT 2014


Author: annakrat
Date: 2014-09-13 10:07:10 -0700 (Sat, 13 Sep 2014)
New Revision: 61897

Modified:
   grass/trunk/gui/wxpython/dbmgr/base.py
   grass/trunk/gui/wxpython/dbmgr/dialogs.py
   grass/trunk/gui/wxpython/dbmgr/vinfo.py
Log:
wxGUI/dbmgr: attempt to fix unicode errors from #1681

Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py	2014-09-13 17:02:59 UTC (rev 61896)
+++ grass/trunk/gui/wxpython/dbmgr/base.py	2014-09-13 17:07:10 UTC (rev 61897)
@@ -850,7 +850,7 @@
                 if enc:
                     sqlFile.write(sql.encode(enc) + ';')
                 else:
-                    sqlFile.write(sql + ';')
+                    sqlFile.write(sql.encode('utf-8') + ';')
                 sqlFile.write(os.linesep)
             sqlFile.close()
 
@@ -1438,14 +1438,13 @@
                     try:
                         if tlist.columns[columnName[i]]['ctype'] == int:
                             # values[i] is stored as text. 
-                            value = float(values[i])
-                        else:
-                            value = values[i]
-                        values[i] = tlist.columns[columnName[i]]['ctype'] (value)
+                            values[i] = int(float(values[i]))
+                        elif tlist.columns[columnName[i]]['ctype'] == float:
+                            values[i] = float(values[i])
                     except:
-                        raise ValueError(_("Value '%(value)s' needs to be entered as %(type)s.") % 
-                                         {'value' : str(values[i]),
-                                          'type' : tlist.columns[columnName[i]]['type']})
+                        raise ValueError(_("Value '%(value)s' needs to be entered as %(type)s.") %
+                                         {'value': values[i],
+                                          'type': tlist.columns[columnName[i]]['type']})
                     columnsString += '%s,' % columnName[i]
                     
                     if tlist.columns[columnName[i]]['ctype'] == str:

Modified: grass/trunk/gui/wxpython/dbmgr/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/dialogs.py	2014-09-13 17:02:59 UTC (rev 61896)
+++ grass/trunk/gui/wxpython/dbmgr/dialogs.py	2014-09-13 17:07:10 UTC (rev 61897)
@@ -242,7 +242,7 @@
                             if ctype != str:
                                 updatedValues.append(str(newvalue))
                             else:
-                                updatedValues.append("'" + str(newvalue) + "'")
+                                updatedValues.append("'" + newvalue + "'")
                         columns[name]['values'][idx] = newvalue
 
                 if self.action != "add" and len(updatedValues) == 0:
@@ -265,7 +265,7 @@
                 if self.action == "add":
                     sqlString += ") VALUES (%s," % cat
                     for value in updatedValues:
-                        sqlString += str(value) + ","
+                        sqlString += value + ","
                     sqlString = sqlString[:-1] # remove last comma
                     sqlString += ")"
                 else:
@@ -327,6 +327,8 @@
                 continue
             if enc:
                 sql = sql.encode(enc)
+            else:
+                sql = sql.encode('utf-8')
             
             driver, database = self.mapDBInfo.GetDbSettings(layer)
             Debug.msg(1, "SQL: %s" % sql)

Modified: grass/trunk/gui/wxpython/dbmgr/vinfo.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/vinfo.py	2014-09-13 17:02:59 UTC (rev 61896)
+++ grass/trunk/gui/wxpython/dbmgr/vinfo.py	2014-09-13 17:07:10 UTC (rev 61897)
@@ -147,7 +147,6 @@
             sql = "SELECT %s FROM %s WHERE %s" % (cols, table, where)
         
         ret = RunCommand('db.select',
-                         parent = self,
                          read = True,
                          quiet = True,
                          flags = 'v',



More information about the grass-commit mailing list