[GRASS-SVN] r31496 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 23 11:24:36 EDT 2008


Author: martinl
Date: 2008-05-23 11:24:36 -0400 (Fri, 23 May 2008)
New Revision: 31496

Modified:
   grass/branches/develbranch_6/gui/wxpython/gis_set.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: wrong indentation fixed (wxgui)
better mapset checking (gis_set)
default connection settings include 'schema/group' (dbm)


Modified: grass/branches/develbranch_6/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gis_set.py	2008-05-23 14:35:45 UTC (rev 31495)
+++ grass/branches/develbranch_6/gui/wxpython/gis_set.py	2008-05-23 15:24:36 UTC (rev 31496)
@@ -541,7 +541,9 @@
         self.listOfMapsetsSelectable = []
         
         for mapset in glob.glob(os.path.join(self.gisdbase, location, "*")):
-            if os.path.isdir(mapset) and os.path.basename(mapset) != 'PERMANENT':
+            if os.path.isdir(mapset) and \
+                    os.path.isfile(os.path.join(self.gisdbase, location, mapset, "WIND")) and \
+                    os.path.basename(mapset) != 'PERMANENT':
                 self.listOfMapsets.append(os.path.basename(mapset))
         
         utils.ListSortLower(self.listOfMapsets)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-05-23 14:35:45 UTC (rev 31495)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2008-05-23 15:24:36 UTC (rev 31496)
@@ -147,6 +147,8 @@
         @return -1 if key column is not displayed
         """
 
+        self.log.write(_("Loading data..."))
+
         # These two should probably be passed to init more cleanly
         # setting the numbers of items = number of elements in the dictionary
         self.itemDataMap  = {}
@@ -2022,26 +2024,24 @@
         #
         # get default values
         #
+        self.defaultConnect = {}
         cmdConnect = gcmd.Command(['db.connect',
                                    '-p',
                                    '--q'])
         for line in cmdConnect.ReadStdOutput():
             item, value = line.split(':')
-            item  = item.strip()
-            value = value.strip()
-            if item == 'driver':
-                self.defaultDriver = value
-            elif item == 'database':
-                self.defaultDatabase = value
+            self.defaultConnect[item.strip()] = value.strip()
 
-        if len(self.defaultDriver) == 0 or \
-               len(self.defaultDatabase) == 0:
+        if len(self.defaultConnect['driver']) == 0 or \
+               len(self.defaultConnect['database']) == 0:
             raise gcmd.DBMError(_('Unable to determine default DB connection settings. '
                                   'Please define DB connection using db.connect module.'))
         
-        self.defaultTables = self.__getTables(self.defaultDriver, self.defaultDatabase)
+        self.defaultTables = self.__getTables(self.defaultConnect['driver'],
+                                              self.defaultConnect['database'])
         try:
-            self.defaultColumns = self.__getColumns(self.defaultDriver, self.defaultDatabase,
+            self.defaultColumns = self.__getColumns(self.defaultConnect['driver'],
+                                                    self.defaultConnect['database'],
                                                     self.defaultTables[0])
         except IndexError:
             self.defaultColumns = []
@@ -2091,8 +2091,8 @@
                                                choices=self.defaultColumns))}
         
         # set default values for widgets
-        self.addLayerWidgets['driver'][1].SetStringSelection(self.defaultDriver)
-        self.addLayerWidgets['database'][1].SetValue(self.defaultDatabase)
+        self.addLayerWidgets['driver'][1].SetStringSelection(self.defaultConnect['driver'])
+        self.addLayerWidgets['database'][1].SetValue(self.defaultConnect['database'])
         self.addLayerWidgets['table'][1].SetSelection(0)
         self.addLayerWidgets['key'][1].SetSelection(0)
         # events
@@ -2343,10 +2343,18 @@
             driver   = self.mapDBInfo.layers[layer]['driver']
             database = self.mapDBInfo.layers[layer]['database']
             table    = self.mapDBInfo.layers[layer]['table']
+
             listOfColumns = self.__getColumns(driver, database, table)
             self.modifyLayerWidgets['driver'][1].SetStringSelection(driver)
             self.modifyLayerWidgets['database'][1].SetValue(database)
-            self.modifyLayerWidgets['table'][1].SetStringSelection(table)
+            if table in self.modifyLayerWidgets['table'][1].GetItems():
+                self.modifyLayerWidgets['table'][1].SetStringSelection(table)
+            else:
+                if self.defaultConnect['schema'] != '':
+                    table = self.defaultConnect['schema'] + table # try with default schema
+                else:
+                    table = 'public.' + table # try with 'public' schema
+                self.modifyLayerWidgets['table'][1].SetStringSelection(table)
             self.modifyLayerWidgets['key'][1].SetItems(listOfColumns)
             self.modifyLayerWidgets['key'][1].SetSelection(0)
 
@@ -2461,15 +2469,18 @@
         table    = self.addLayerWidgets['table'][1]
         key      = self.addLayerWidgets['key'][1]
 
-        driver.SetStringSelection(self.defaultDriver)
-        database.SetValue(self.defaultDatabase)
-        tables = self.__getTables(self.defaultDriver, self.defaultDatabase)
+        driver.SetStringSelection(self.defaultConnect['driver'])
+        database.SetValue(self.defaultConnect['database'])
+        tables = self.__getTables(self.defaultConnect['driver'],
+                                  self.defaultConnect['database'])
         table.SetItems(tables)
         table.SetSelection(0)
         if len(tables) == 0:
             key.SetItems([])
         else:
-            cols = self.__getColumns(self.defaultDriver, self.defaultDatabase, tables[0])
+            cols = self.__getColumns(self.defaultConnect['driver'],
+                                     self.defaultConnect['database'],
+                                     tables[0])
             key.SetItems(cols)
             key.SetSelection(0)
 

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-23 14:35:45 UTC (rev 31495)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-23 15:24:36 UTC (rev 31496)
@@ -1162,7 +1162,7 @@
         busy = wx.BusyInfo(message=_("Please wait, loading attribute data..."),
                            parent=self)
         wx.Yield()
-
+        
         self.dbmanager = dbm.AttributeManager(parent=self, id=wx.ID_ANY,
                                               title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
                                                                    mapname),



More information about the grass-commit mailing list