From 105e8688641c0a98f7020a81e7a15744f25cc991 Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Sun, 5 Jul 2009 23:33:09 +0300 Subject: [PATCH] Catch local connection config If database backend is Postgres and the connection is over domain socket, the only values in node are: * db_name * db_server * db_type Now, for some reason the config reader unconditionally creates "tidy" string representations for all possible keys. This means that host, user and password are all empty strings (''), and not even NoneType entities. To catch the case for postgres, simply treat empty host the same as undefined host. --- pyfpdb/fpdb_db.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index f89b5d6d..669ba4f0 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -182,7 +182,9 @@ class fpdb_db: # sqlcoder: This database only connect failed in my windows setup?? # Modifed it to try the 4 parameter style if the first connect fails - does this work everywhere? connected = False - if self.host == "localhost" or self.host == "127.0.0.1": + if self.host == None or self.host == '' \ + or self.host == "localhost" \ + or self.host == "127.0.0.1": try: self.db = psycopg2.connect(database = database) connected = True