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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 26 08:40:18 PDT 2014


Author: martinl
Date: 2014-03-26 08:40:17 -0700 (Wed, 26 Mar 2014)
New Revision: 59372

Modified:
   grass/trunk/gui/wxpython/dbmgr/base.py
   grass/trunk/gui/wxpython/dbmgr/vinfo.py
Log:
wxGUI/dbmgr: fix inserting records


Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py	2014-03-26 15:39:13 UTC (rev 59371)
+++ grass/trunk/gui/wxpython/dbmgr/base.py	2014-03-26 15:40:17 UTC (rev 59372)
@@ -817,7 +817,10 @@
             self.dbMgrData['mapDBInfo'].GetColumns(table)
 
     def ApplyCommands(self, listOfCommands, listOfSQLStatements):
-        """!Apply changes"""
+        """!Apply changes
+
+        @todo: this part should be _completely_ redesigned
+        """
         # perform GRASS commands (e.g. v.db.addcolumn)
         wx.BeginBusyCursor()
         
@@ -867,7 +870,7 @@
             os.close(fd)
             os.remove(sqlFilePath)
             # reset list of statements
-            listOfSQLStatements = []
+            self.listOfSQLStatements = []
             
         wx.EndBusyCursor()        
 
@@ -1430,7 +1433,7 @@
                                                " is missing.") % keyColumn)
                         else:
                             continue
-
+                    
                     try:
                         if tlist.columns[columnName[i]]['ctype'] == int:
                             # values[i] is stored as text. 
@@ -1438,17 +1441,17 @@
                         else:
                             value = values[i]
                         values[i] = tlist.columns[columnName[i]]['ctype'] (value)
-
                     except:
                         raise ValueError(_("Value '%(value)s' needs to be entered as %(type)s.") % 
                                          {'value' : str(values[i]),
                                           'type' : tlist.columns[columnName[i]]['type']})
                     columnsString += '%s,' % columnName[i]
+                    
                     if tlist.columns[columnName[i]]['ctype'] == str:
                         valuesString += "'%s'," % values[i]
                     else:
                         valuesString += "%s," % values[i]
-
+                
             except ValueError, err:
                 GError(parent = self,
                        message = _("Unable to insert new record.\n%s") % err,
@@ -1473,8 +1476,9 @@
 
             self.listOfSQLStatements.append('INSERT INTO %s (%s) VALUES(%s)' % \
                                                 (table,
-                                                 columnsString.strip(','),
-                                                 valuesString.strip(',')))
+                                                 columnsString.rstrip(','),
+                                                 valuesString.rstrip(',')))
+            
             self.ApplyCommands(self.listOfCommands, self.listOfSQLStatements)
 
         

Modified: grass/trunk/gui/wxpython/dbmgr/vinfo.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/vinfo.py	2014-03-26 15:39:13 UTC (rev 59371)
+++ grass/trunk/gui/wxpython/dbmgr/vinfo.py	2014-03-26 15:40:17 UTC (rev 59372)
@@ -41,7 +41,7 @@
     else:
         enc = 'utf-8' # assuming UTF-8
     
-    return unicode(value, enc, errors = 'replace')
+    return unicode(str(value), enc, errors = 'replace')
 
 def CreateDbInfoDesc(panel, mapDBInfo, layer):
     """!Create database connection information content"""



More information about the grass-commit mailing list