Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv22825/SQLObject
Modified Files:
DBConnection.py
Log Message:
Cleaned up imports, so we only import the drivers that we need.
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** DBConnection.py 6 Sep 2003 02:33:17 -0000 1.42
--- DBConnection.py 6 Sep 2003 02:37:42 -0000 1.43
***************
*** 4,41 ****
import threading
import SQLBuilder
from Cache import CacheSet
import Col
- try:
- import cPickle as pickle
- except ImportError:
- import pickle
- import os
- import anydbm
from Join import sorter
! try:
! import MySQLdb
! except ImportError:
! MySQLdb = None
!
! try:
! import psycopg
! except ImportError:
! psycopg = None
!
! try:
! import sqlite
! except ImportError:
! sqlite = None
!
! try:
! import kinterbasdb
! except ImportError:
! kinterbasdb = None
!
! import re
! import warnings
! import atexit
warnings.filterwarnings("ignore", "DB-API extension cursor.lastrowid used")
--- 4,24 ----
import threading
+ import re
+ import warnings
+ import atexit
+ import os
import SQLBuilder
from Cache import CacheSet
import Col
from Join import sorter
! # We set these up as globals, which will be set if we end up
! # needing the drivers:
! anydbm = None
! pickle = None
! MySQLdb = None
! psycopg = None
! sqlite = None
! kinterbasdb = None
warnings.filterwarnings("ignore", "DB-API extension cursor.lastrowid used")
***************
*** 361,365 ****
def __init__(self, db, user, passwd='', host='localhost', **kw):
! assert MySQLdb, 'MySQLdb module cannot be found'
self.host = host
self.db = db
--- 344,350 ----
def __init__(self, db, user, passwd='', host='localhost', **kw):
! global MySQLdb
! if MySQLdb is None:
! import MySQLdb
self.host = host
self.db = db
***************
*** 446,450 ****
def __init__(self, dsn=None, host=None, db=None,
user=None, passwd=None, autoCommit=1, **kw):
! assert psycopg, 'psycopg module cannot be found'
if not autoCommit and not kw.has_key('pool'):
# Pooling doesn't work with transactions...
--- 431,437 ----
def __init__(self, dsn=None, host=None, db=None,
user=None, passwd=None, autoCommit=1, **kw):
! global psycopg
! if psycopg is None:
! import psycopg
if not autoCommit and not kw.has_key('pool'):
# Pooling doesn't work with transactions...
***************
*** 569,573 ****
def __init__(self, filename, autoCommit=1, **kw):
! assert sqlite, 'sqlite module cannot be found'
self.filename = filename # full path to sqlite-db-file
if not autoCommit and not kw.has_key('pool'):
--- 556,562 ----
def __init__(self, filename, autoCommit=1, **kw):
! global sqlite
! if sqlite is None:
! import sqlite
self.filename = filename # full path to sqlite-db-file
if not autoCommit and not kw.has_key('pool'):
***************
*** 620,624 ****
def __init__(self, host, db, user='sysdba',
passwd='masterkey', autoCommit=1, **kw):
! assert kinterbasdb, 'kinterbasdb module cannot be found'
self.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE)
--- 609,615 ----
def __init__(self, host, db, user='sysdba',
passwd='masterkey', autoCommit=1, **kw):
! global kinterbasdb
! if kinterbasdb is None:
! import kinterbasdb
self.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE)
***************
*** 866,869 ****
--- 857,868 ----
def __init__(self, path, **kw):
+ global anydbm, pickle
+ if anydbm is None:
+ import anydbm
+ if pickle is None:
+ try:
+ import cPickle as pickle
+ except ImportError:
+ import pickle
self.path = path
try:
|