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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 19 03:01:31 EDT 2008


Author: martinl
Date: 2008-07-19 03:01:28 -0400 (Sat, 19 Jul 2008)
New Revision: 32166

Modified:
   grass/trunk/gui/wxpython/gui_modules/dbm.py
   grass/trunk/gui/wxpython/gui_modules/vdigit.py
Log:
wxGUI/dbm: don't use fixed column key name (cat)

Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-07-18 20:18:51 UTC (rev 32165)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-07-19 07:01:28 UTC (rev 32166)
@@ -2797,12 +2797,13 @@
         # find updated values for each layer/category
         for layer in self.mapDBInfo.layers.keys(): # for each layer
             table = self.mapDBInfo.layers[layer]["table"]
+            key = self.mapDBInfo.layers[layer]["key"]
             columns = self.mapDBInfo.tables[table]
-            for idx in range(len(columns["cat"]['values'])): # for each category
+            for idx in range(len(columns[key]['values'])): # for each category
                 updatedColumns = []
                 updatedValues = []
                 for name in columns.keys():
-                    if name == "cat":
+                    if name == key:
                         cat = columns[name]['values'][idx]
                         continue
                     type  = columns[name]['type']
@@ -2831,7 +2832,7 @@
                     continue
 
                 if self.action == "add":
-                    sqlString = "INSERT INTO %s (cat," % table
+                    sqlString = "INSERT INTO %s (%s," % (table, key)
                 else:
                     sqlString = "UPDATE %s SET " % table
 
@@ -2864,13 +2865,14 @@
         """Reset form"""
         for layer in self.mapDBInfo.layers.keys():
             table = self.mapDBInfo.layers[layer]["table"]
+            key = self.mapDBInfo.layers[layer]["key"]
             columns = self.mapDBInfo.tables[table]
-            for idx in range(len(columns["cat"]['values'])):
+            for idx in range(len(columns[key]['values'])):
                 for name in columns.keys():
                     type  = columns[name]['type']
                     value = columns[name]['values'][idx]
                     id    = columns[name]['ids'][idx]
-                    if name.lower() != "cat":
+                    if name.lower() != key:
                         self.FindWindowById(id).SetValue(str(value))
 
     def OnCancel(self, event):
@@ -2927,7 +2929,10 @@
             if not query: # select by layer/cat
                 if cats.has_key(layer): 
                     for cat in cats[layer]:
-                        nselected = self.mapDBInfo.SelectFromTable(layer, where="cat=%d" % cat)
+                        nselected = self.mapDBInfo.SelectFromTable(layer,
+                                                                   where="%s=%d" % \
+                                                                       (self.mapDBInfo.layers[layer]['key'],
+                                                                        cat))
                 else:
                     nselected = 0
 
@@ -2938,9 +2943,10 @@
                 if nselected <= 0:
                     if cats.has_key(layer):
                         table = self.mapDBInfo.layers[layer]["table"]
+                        key = self.mapDBInfo.layers[layer]["key"]
                         columns = self.mapDBInfo.tables[table]
                         for name in columns.keys():
-                            if name == "cat":
+                            if name == key:
                                 for cat in cats[layer]:
                                     self.mapDBInfo.tables[table][name]['values'].append(cat)
                             else:
@@ -2960,10 +2966,11 @@
             border = wx.BoxSizer(wx.VERTICAL)
 
             table   = self.mapDBInfo.layers[layer]["table"]
+            key   = self.mapDBInfo.layers[layer]["key"]
             columns = self.mapDBInfo.tables[table]
 
             # value
-            if len(columns["cat"]['values']) == 0: # no cats
+            if len(columns[key]['values']) == 0: # no cats
                 sizer  = wx.BoxSizer(wx.VERTICAL)
                 txt = wx.StaticText(parent=panel, id=wx.ID_ANY,
                                     label=_("No database record available."))
@@ -2974,7 +2981,7 @@
                            border=10)
                 panel.SetSizer(border)
                 continue
-            for idx in range(len(columns["cat"]['values'])):
+            for idx in range(len(columns[key]['values'])):
                 flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3)
                 flexSizer.AddGrowableCol(3)
                 # columns
@@ -2985,7 +2992,7 @@
                     else:
                         value = ''
 
-                    if name.lower() == "cat":
+                    if name.lower() == key:
                         box    = wx.StaticBox (parent=panel, id=wx.ID_ANY,
                                                label=" %s %s " % (_("Category"), value))
                         boxFont = self.GetFont()
@@ -3188,7 +3195,7 @@
                                       "database=%s" % self.layers[layer]["database"],
                                       "driver=%s"   % self.layers[layer]["driver"]])
 
-        # self.tables[table]["cat"][1] = str(cat)
+        # self.tables[table][key][1] = str(cat)
         if selectCommand.returncode == 0:
             for line in selectCommand.ReadStdOutput():
                 name, value = line.split('|')

Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py	2008-07-18 20:18:51 UTC (rev 32165)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py	2008-07-19 07:01:28 UTC (rev 32166)
@@ -140,18 +140,21 @@
         try:
             ret = self.driver.Reset(self.map)
         except StandardError, e:
-            raise gcmd.DigitError('Unable to initialize display driver, '
-                                  'see README file for more information.%s%s'
-                                  'Details: %s (%s)' % (os.linesep, os.linesep, e, digitErr))
+            raise gcmd.DigitError(parent=self.mapWindow.parent,
+                                  message=_('Unable to initialize display driver, '
+                                            'see README file for more information.%s%s'
+                                            'Details: %s (%s)') % (os.linesep, os.linesep, e, digitErr))
         
         if map and ret == -1:
-            raise gcmd.DigitError(_('Unable to open vector map <%s> for editing. '
-                                    'Data are probably corrupted, '
-                                    'try to run v.build for rebuilding the topology.') % map)
+            raise gcmd.DigitError(parent=self.mapWindow.parent,
+                                  message=_('Unable to open vector map <%s> for editing. '
+                                            'Data are probably corrupted, '
+                                            'try to run v.build for rebuilding the topology.') % map)
         if not map and ret != 0:
-            raise gcmd.DigitError(_('Unable to open vector map <%s> for editing. '
-                                    'Data are probably corrupted, '
-                                    'try to run v.build for rebuilding the topology.') % map)
+            raise gcmd.DigitError(parent=self.mapWindow.parent,
+                                  message=_('Unable to open vector map <%s> for editing. '
+                                            'Data are probably corrupted, '
+                                            'try to run v.build for rebuilding the topology.') % map)
             
         if UserSettings.Get(group='advanced', key='digitInterface', subkey='type') != 'v.edit':
             try:



More information about the grass-commit mailing list