[SQL-CVS] r1166 - in SQLObject/trunk/sqlobject: . postgres
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-10-28 15:34:35
|
Author: phd
Date: 2005-10-28 15:34:24 +0000 (Fri, 28 Oct 2005)
New Revision: 1166
Modified:
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/postgres/__init__.py
SQLObject/trunk/sqlobject/postgres/pgconnection.py
Log:
Adapted to psycopg2.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2005-10-28 12:46:06 UTC (rev 1165)
+++ SQLObject/trunk/sqlobject/col.py 2005-10-28 15:34:24 UTC (rev 1166)
@@ -30,7 +30,7 @@
from formencode import compound
from formencode import validators
from classregistry import findClass
-from converters import array_type
+from converters import array_type, buffer_type
from util.backports import count
NoDefault = sqlbuilder.NoDefault
@@ -1162,7 +1162,7 @@
if module.__name__ == "sqlite":
value = module.decode(value)
return value
- if isinstance(value, state.soObject._connection._binaryType):
+ if isinstance(value, (buffer_type, state.soObject._connection._binaryType)):
cachedValue = self._cachedValue
if cachedValue and cachedValue[1] == value:
return cachedValue[0]
Modified: SQLObject/trunk/sqlobject/postgres/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/__init__.py 2005-10-28 12:46:06 UTC (rev 1165)
+++ SQLObject/trunk/sqlobject/postgres/__init__.py 2005-10-28 15:34:24 UTC (rev 1166)
@@ -6,9 +6,12 @@
def isSupported():
try:
- import psycopg
+ import psycopg2
except ImportError:
- return False
+ try:
+ import psycopg
+ except ImportError:
+ return False
return True
registerConnection(['postgres', 'postgresql', 'psycopg'],
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-28 12:46:06 UTC (rev 1165)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-28 15:34:24 UTC (rev 1166)
@@ -23,7 +23,10 @@
self.module = pgdb
else:
if psycopg is None:
- import psycopg
+ try:
+ import psycopg2 as psycopg
+ except ImportError:
+ import psycopg
self.module = psycopg
# Register a converter for psycopg Binary type.
|