fix quit option and postgres/windows connecting after last merges

This commit is contained in:
sqlcoder 2009-06-09 21:38:30 +01:00
parent 8a55b2ebd9
commit 9d87e35082
2 changed files with 22 additions and 7 deletions

View File

@ -409,7 +409,7 @@ class fpdb:
return self.fdb_lock.get_global_lock() return self.fdb_lock.get_global_lock()
#end def obtain_global_lock #end def obtain_global_lock
def quit(self, widget, data): def quit(self, widget, data=None):
print "Quitting normally" print "Quitting normally"
#check if current settings differ from profile, if so offer to save or abort #check if current settings differ from profile, if so offer to save or abort
self.db.disconnect() self.db.disconnect()

View File

@ -179,13 +179,28 @@ class fpdb_db:
# For local domain-socket connections, only DB name is # For local domain-socket connections, only DB name is
# needed, and everything else is in fact undefined and/or # needed, and everything else is in fact undefined and/or
# flat out wrong # flat out wrong
# 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 == "localhost" or self.host == "127.0.0.1":
try:
self.db = psycopg2.connect(database = database) self.db = psycopg2.connect(database = database)
else: connected = True
except:
pass
#msg = "PostgreSQL direct connection to database (%s) failed, trying with user ..." % (database,)
#print msg
#raise fpdb_simple.FpdbError(msg)
if not connected:
try:
self.db = psycopg2.connect(host = host, self.db = psycopg2.connect(host = host,
user = user, user = user,
password = password, password = password,
database = database) database = database)
except:
msg = "PostgreSQL connection to database (%s) user (%s) failed." % (database, user)
print msg
raise fpdb_simple.FpdbError(msg)
else: else:
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend) raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
self.cursor=self.db.cursor() self.cursor=self.db.cursor()