COM callbacks in Python

Dan danbrwn at gmail.com
Fri Mar 24 09:46:41 EST 2006


Looked at the makepy, code now looks like this:
import win32com.client
import win32gui
import time
import pythoncom
finished = 0
defaultNamedNotOptArg=pythoncom.Empty
class ADOEvents:
		def OnRecordsetChangeComplete(self, adReason=defaultNamedNotOptArg,
pError=defaultNamedNotOptArg, adStatus=pythoncom.Missing,
pRecordset=defaultNamedNotOptArg):
			print "recordset has changed"
			global finished
			finished=1
connect = win32com.client.Dispatch("ADODB.Connection")
recordset =
win32com.client.DispatchWithEvents("ADODB.Recordset",ADOEvents)
connect.Open("Driver={SQL
Server};Server=devserver;Database=VidVisitation;UID=sa;PWD=;")
datestring = time.strftime("%m/%d/%Y")
sql = "Select * from VisSchedule where SDATE='" + datestring +"'"
recordset.Open(sql,connect)
while not finished:
     win32gui.PumpMessages()
     pass

any idea why it doesn't work? Ive not really seen much on this in the
newsgroups so any help would be greatly appreciated. I came upon a post
by Paul Moore and and angusm describing code like this. angusm
suggested that all of the interfaces must be implemented within the
Events class, while Paul Moore suggested they didn't. Who is right?
Here is the link to the thread:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/96cb2174570d92a1/b52f9ce9ac6403f4?lnk=st&q=paul+moore+angusm&rnum=1&hl=en#b52f9ce9ac6403f4




More information about the Python-list mailing list