[SQLObject] problem with port setting for psycopg 1.1.21
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Robert F. <xro...@go...> - 2006-12-03 15:56:37
|
hi, just installed SQLObject-0.7.2b1-py2.4 on Ubuntu Dapper. PostgreSQL 8.1 listens on port 5433 by default, and psycopg 1.1.21 is installed. Unfortunately, psycopg's connect function expects the port as str and not as int: >>> c.makeConnection() Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py", line 110, in makeConnection conn = self.module.connect(**self.dsn_dict) TypeError: argument 4 must be string, not int The following patch root@rostrum:/etc/postgresql# diff -Naur /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/old_pgconnection.py /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py --- /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/old_pgconnection.py 2006-12-03 16:51:12.000000000 +0100 +++ /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py 2006-12-03 16:28:16.000000000 +0100 @@ -107,6 +107,8 @@ if self.use_dsn: conn = self.module.connect(self.dsn) else: + if 'port' in self.dsn_dict: + self.dsn_dict['port'] = str(self.dsn_dict['port']) conn = self.module.connect(**self.dsn_dict) except self.module.OperationalError, e: raise self.module.OperationalError("%s; used connection string %r" % (e, self.dsn)) solved the problem for me, but i don't know - and cannot test - whether this modification is compatible with other postgres adapters. regards, robert |