Update of /cvsroot/jtoolkit/jToolkit/data
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8053
Modified Files:
_PyADO.py
Log Message:
changed hex constant to LONG to avoid FutureWarning on Python 2.3 (should stil work with Python 2.2)
Index: _PyADO.py
===================================================================
RCS file: /cvsroot/jtoolkit/jToolkit/data/_PyADO.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** _PyADO.py 9 Feb 2004 14:04:47 -0000 1.2
--- _PyADO.py 9 Mar 2004 21:20:20 -0000 1.3
***************
*** 25,28 ****
--- 25,56 ----
import win32com.client
+ try:
+ from jToolkit.data import ADODB
+ if not hasattr(ADODB, "Connection"):
+ print "Connection not found in jToolkit.data.ADODB: remove %s to recreate it" % ADODB.__file__
+ ADODB = None
+ except ImportError:
+ import sys
+ import os.path
+ from win32com.client import makepy
+ # get version from test connection
+ print "creating jToolkit.data.ADODB class library to speed up database operations..."
+ conn = win32com.client.Dispatch("ADODB.Connection")
+ version = str(conn.Version)
+ classname = "Microsoft ActiveX Data Objects %s Library" % version
+ pyclassfilename = os.path.join(os.path.dirname(__file__), 'ADODB.py')
+ pyclassfile = open(pyclassfilename, 'w')
+ print "creating %s for %s" % (pyclassfile, classname)
+ makepy.GenerateFromTypeLibSpec(classname, pyclassfile)
+ pyclassfile.close()
+ if not os.path.getsize(pyclassfilename):
+ print "ADO class creation unsuccessful... removing"
+ os.remove(pyclassfilename)
+ try:
+ from jToolkit.data import ADODB
+ except ImportError:
+ print "could not import ADODB module even after attempted recreation: running slowly..."
+ ADODB = None
+
CoInitialize = win32com.client.pythoncom.CoInitialize
error = pythoncom.error
***************
*** 40,46 ****
def __init__(self):
try:
! self.Conn = win32com.client.Dispatch("ADODB.Connection")
except win32com.client.pythoncom.com_error, com_error:
! if com_error.args[0] == 0x800401f0:
# this is the COM not initialized problem
raise WindowsError("COM not initialized")
--- 68,77 ----
def __init__(self):
try:
! if ADODB:
! self.Conn = ADODB.Connection()
! else:
! self.Conn = win32com.client.Dispatch("ADODB.Connection")
except win32com.client.pythoncom.com_error, com_error:
! if com_error.args[0] == 0x800401f0L:
# this is the COM not initialized problem
raise WindowsError("COM not initialized")
***************
*** 93,97 ****
class Recordset(object):
def __init__(self):
! self.rs = win32com.client.Dispatch("ADODB.Recordset")
def Open(self, operation, ActiveConnection):
return self.rs.Open(operation, ActiveConnection.Conn)
--- 124,131 ----
class Recordset(object):
def __init__(self):
! if ADODB:
! self.rs = ADODB.Recordset()
! else:
! self.rs = win32com.client.Dispatch("ADODB.Recordset")
def Open(self, operation, ActiveConnection):
return self.rs.Open(operation, ActiveConnection.Conn)
|