[GRASS-SVN] r54841 - grass/trunk/gui/wxpython/dbmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Feb 2 09:32:40 PST 2013
Author: martinl
Date: 2013-02-02 09:32:39 -0800 (Sat, 02 Feb 2013)
New Revision: 54841
Modified:
grass/trunk/gui/wxpython/dbmgr/base.py
grass/trunk/gui/wxpython/dbmgr/dialogs.py
grass/trunk/gui/wxpython/dbmgr/sqlbuilder.py
grass/trunk/gui/wxpython/dbmgr/vinfo.py
Log:
wxGUI/dbmgr: fix updating existing attributes (encoding and casting issues)
Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py 2013-02-02 17:06:19 UTC (rev 54840)
+++ grass/trunk/gui/wxpython/dbmgr/base.py 2013-02-02 17:32:39 UTC (rev 54841)
@@ -45,7 +45,7 @@
from core.gcmd import RunCommand, GException, GError, GMessage, GWarning
from core.utils import ListOfCatsToRange
from gui_core.dialogs import CreateNewVector
-from dbmgr.vinfo import VectorDBInfo, unicodeValue, createDbInfoDesc
+from dbmgr.vinfo import VectorDBInfo, GetUnicodeValue, CreateDbInfoDesc
from core.debug import Debug
from dbmgr.dialogs import ModifyTableRecord, AddColumnDialog
from core.settings import UserSettings
@@ -289,7 +289,7 @@
else:
# encode string values
try:
- self.itemDataMap[i].append(unicodeValue(value))
+ self.itemDataMap[i].append(GetUnicodeValue(value))
except UnicodeDecodeError:
self.itemDataMap[i].append(_("Unable to decode value. "
"Set encoding in GUI preferences ('Attributes')."))
@@ -1298,10 +1298,6 @@
idx = i
if column['ctype'] != types.StringType:
- if column['ctype'] == types.IntegerType:
- value = float(values[i])
- else:
- value = values[i]
tlist.itemDataMap[item][idx] = column['ctype'] (value)
else: # -> string
tlist.itemDataMap[item][idx] = values[i]
@@ -1949,7 +1945,7 @@
dbBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
label = " %s " % _("Database connection"))
dbSizer = wx.StaticBoxSizer(dbBox, wx.VERTICAL)
- dbSizer.Add(item = createDbInfoDesc(panel, self.dbMgrData['mapDBInfo'], layer),
+ dbSizer.Add(item = CreateDbInfoDesc(panel, self.dbMgrData['mapDBInfo'], layer),
proportion = 1,
flag = wx.EXPAND | wx.ALL,
border = 3)
Modified: grass/trunk/gui/wxpython/dbmgr/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/dialogs.py 2013-02-02 17:06:19 UTC (rev 54840)
+++ grass/trunk/gui/wxpython/dbmgr/dialogs.py 2013-02-02 17:32:39 UTC (rev 54841)
@@ -8,7 +8,7 @@
- dialogs::ModifyTableRecord
- dialogs::AddColumnDialog
-(C) 2007-2012 by the GRASS Development Team
+(C) 2007-2013 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -27,7 +27,7 @@
from core.gcmd import RunCommand, GError
from core.debug import Debug
from core.settings import UserSettings
-from dbmgr.vinfo import VectorDBInfo
+from dbmgr.vinfo import VectorDBInfo, GetUnicodeValue
from gui_core.widgets import IntegerValidator, FloatValidator
class DisplayAttributesDialog(wx.Dialog):
@@ -692,17 +692,17 @@
If columns is given (list), return only values of given columns.
"""
- valueList = []
+ valueList = list()
for labelId, ctypeId, valueId in self.widgets:
- column = self.FindWindowById(labelId).GetLabel().replace(':', '')
+ column = self.FindWindowById(labelId).GetLabel()
if columns is None or column in columns:
- value = str(self.FindWindowById(valueId).GetValue())
+ value = GetUnicodeValue(self.FindWindowById(valueId).GetValue())
valueList.append(value)
# add key value
if self.usebox:
- valueList.insert(self.keyId, str(self.cat))
-
+ valueList.insert(self.keyId, GetUnicodeValue(str(self.cat)))
+
return valueList
class AddColumnDialog(wx.Dialog):
Modified: grass/trunk/gui/wxpython/dbmgr/sqlbuilder.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/sqlbuilder.py 2013-02-02 17:06:19 UTC (rev 54840)
+++ grass/trunk/gui/wxpython/dbmgr/sqlbuilder.py 2013-02-02 17:32:39 UTC (rev 54841)
@@ -33,7 +33,7 @@
import wx
from core.gcmd import RunCommand, GError, GMessage
-from dbmgr.vinfo import createDbInfoDesc, VectorDBInfo
+from dbmgr.vinfo import CreateDbInfoDesc, VectorDBInfo
import grass.script as grass
@@ -81,7 +81,7 @@
databasebox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
label = " %s " % _("Database connection"))
databaseboxsizer = wx.StaticBoxSizer(databasebox, wx.VERTICAL)
- databaseboxsizer.Add(item=createDbInfoDesc(self.panel, self.dbInfo, layer = self.layer),
+ databaseboxsizer.Add(item = CreateDbInfoDesc(self.panel, self.dbInfo, layer = self.layer),
proportion=1,
flag=wx.EXPAND | wx.ALL,
border=3)
Modified: grass/trunk/gui/wxpython/dbmgr/vinfo.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/vinfo.py 2013-02-02 17:06:19 UTC (rev 54840)
+++ grass/trunk/gui/wxpython/dbmgr/vinfo.py 2013-02-02 17:32:39 UTC (rev 54841)
@@ -22,11 +22,15 @@
from gui_core.gselect import VectorDBInfo as VectorDBInfoBase
from core.gcmd import RunCommand
from core.settings import UserSettings
-
import grass.script as grass
-def unicodeValue(value):
- """!Encode value"""
+def GetUnicodeValue(value):
+ """!Get unicode value
+
+ @param value value to be recoded
+
+ @return unicode value
+ """
if type(value) == types.UnicodeType:
return value
@@ -37,8 +41,8 @@
enc = 'utf-8' # assuming UTF-8
return unicode(value, enc, errors = 'replace')
-
-def createDbInfoDesc(panel, mapDBInfo, layer):
+
+def CreateDbInfoDesc(panel, mapDBInfo, layer):
"""!Create database connection information content"""
infoFlexSizer = wx.FlexGridSizer (cols = 2, hgap = 1, vgap = 1)
infoFlexSizer.AddGrowableCol(1)
@@ -111,7 +115,7 @@
if self.tables[table][key]['ctype'] != types.StringType:
value = self.tables[table][key]['ctype'] (value)
else:
- value = unicodeValue(value)
+ value = GetUnicodeValue(value)
self.tables[table][key]['values'].append(value)
for key, value in record.iteritems():
@@ -159,7 +163,7 @@
if self.tables[table][name]['ctype'] != type(''):
value = self.tables[table][name]['ctype'] (value)
else:
- value = unicodeValue(value)
+ value = GetUnicodeValue(value)
else:
value = None
self.tables[table][name]['values'].append(value)
More information about the grass-commit
mailing list