KeyError: _dispobj_ in new python COM server
craig curtin
curtin at ubsw.com
Fri Jan 18 11:08:56 EST 2002
hi,
i'm creating a COM server and get the following error when
i try to assign anything to self. i'm trying to build a
COM wrapper server to handle Async events. i've dummied down
my code without any luck.
tia,
craig
-- Error ---------------
Registering COM server...
Registered: PythonExchange.AsyncEvents
Traceback (most recent call last):
File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line
301, in RunScript
exec codeObject in __main__.__dict__
File "\\Dellsrv0\Magic Bus\curtin\ExchangeCOMStuff\E2KSinkRC1.py",
line 32, in ?
pyAE = AsyncEvents()
File "\\Dellsrv0\Magic Bus\curtin\ExchangeCOMStuff\E2KSinkRC1.py",
line 14, in __init__
self.wfd = open( fname, 'w')
File "C:\Python21\win32com\gen_py\6593D6E1-8A3E-427F-A12C-0CA15B4FD865x0x1x0.py",
line 62, in __setattr__
d=self.__dict__["_dispobj_"]
KeyError: _dispobj_
>>>
--- Code --------------------
import os, time
from win32com.client import gencache, constants
sinkServer=gencache.EnsureModule('{6593D6E1-8A3E-427F-A12C-0CA15B4FD865}',
0, 1, 0)
class AsyncEvents(sinkServer.AsyncEvents):
_public_methods_ = [ 'OnSave', 'OnDelete' ]
_reg_progid_ = 'PythonExchange.AsyncEvents'
_reg_clsid_ = '{5D342119-D3CD-446B-9AA5-C8427DE0BBB1}'
def __init__(self, obj=None):
#create a temporary file for trace messages
fname = '%s\\E2kSink%s.txt' % (os.environ['TEMP'], os.getpid())
self.wfd = open( fname, 'w')
if obj is not None:
sinkServer.AsyncEvents.__init__(self, obj)
def OnSave(self, pEventInfo, bstrURLItem, lFlags):
s = '%s called [%s]' % ( 'OnSave()', time.ctime())
print s
self.wfd.write(s)
pass
def OnDelete(self, pEventInfo, bstrURLItem, lFlags):
s = '%s called [%s]' % ( 'OnDelete()', time.ctime())
print s
self.wfd.write(s)
pass
if __name__ == '__main__':
print 'Registering COM server...'
import win32com.server.register
win32com.server.register.UseCommandLine(AsyncEvents)
pyAE = AsyncEvents()
pyAE.OnSave('one', 'two', 'three')
pyAE.OnDelete('one', 'two', 'three')
More information about the Python-list
mailing list