From f6f9932477b8ee15b7b4dc330aa43dd14e401e7c Mon Sep 17 00:00:00 2001 From: Radek Pasiok Date: Fri, 27 Jan 2017 17:31:54 +0100 Subject: [PATCH] fix for #1 --- GeoCat/dbutils.py | 3 ++- GeoCat/geo_cat.py | 1 + GeoCat/geo_cat_dialog.py | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/GeoCat/dbutils.py b/GeoCat/dbutils.py index 17373f1..a26c2c5 100644 --- a/GeoCat/dbutils.py +++ b/GeoCat/dbutils.py @@ -58,8 +58,9 @@ def get_postgres_conn_info(selected): return {} conn_info = {} + conn_info['dsn'] = None conn_info["host"] = settings.value("host", "", type=str) - conn_info["port"] = settings.value("port", 432, type=int) + conn_info["port"] = settings.value("port", 5432, type=int) conn_info["database"] = settings.value("database", "", type=str) username = settings.value("username", "", type=str) password = settings.value("password", "", type=str) diff --git a/GeoCat/geo_cat.py b/GeoCat/geo_cat.py index cb7f07d..cbc14e3 100644 --- a/GeoCat/geo_cat.py +++ b/GeoCat/geo_cat.py @@ -185,6 +185,7 @@ def unload(self): def run(self): """Run method that performs all the real work""" + self.dlg._setup_config() # refresh custom columns widgets self.dlg.setup_custom_widgets() # clear any previuos search text and results diff --git a/GeoCat/geo_cat_dialog.py b/GeoCat/geo_cat_dialog.py index 6bec4d1..2f4719a 100644 --- a/GeoCat/geo_cat_dialog.py +++ b/GeoCat/geo_cat_dialog.py @@ -105,12 +105,13 @@ def _setup_config(self): self.config['cat_table'] = '"%s"' % s.value('GeoCat/metadataTableName', '', type=str) self.config['title_col'] = '"%s"' % s.value('GeoCat/titleColumn', '', type=str) self.config['abstract_col'] = '"%s"' % s.value('GeoCat/abstractColumn', '', type=str) - self.config['date_col'] = '"date_published"' # TODO self.config['schema_col'] = '"%s"' % s.value('GeoCat/gisLayerSchemaCol', '', type=str) self.config['table_col'] = '"%s"' % s.value('GeoCat/gisLayerTableCol', '', type=str) def _db_cur(self): con_info = get_postgres_conn_info(self.config['connection']) + if not self.config['connection']: + return None con = get_connection(con_info) return con.cursor(cursor_factory=DictCursor) @@ -133,6 +134,9 @@ def search(self): # import pydevd; pydevd.settrace('localhost', port=5678) cur = self._db_cur() + if not cur: + self.bar_warn('There is no connection defined.') + return search_text = self.searchLineEdit.text() @@ -166,7 +170,6 @@ def search(self): SELECT cat.""" + self.config['title_col'] + """, cat.""" + self.config['abstract_col'] + """, - -- cat.""" + self.config['date_col'] + """, cat.""" + self.config['schema_col'] + """, cat.""" + self.config['table_col'] + """, gc.f_geometry_column,