On 2/03/2010 9:10 AM, Ulrich Mierendorff wrote:
Hi,

I have implemented a simple com server called "TestServer" using the
following mail as an example
http://markmail.org/message/vheujc2lijgwhhju#query:+page:1+mid:4lgd7lzzokglsckc+state:results

(but without multi-threading support)

Now I want to write a python client that should be able to connect to
"TestServer" via COM and receive events. Connecting to the server and
calling methods is easy: I just use win32com.client.Dispatch(..).

As far as I know I have to use DispatchWithEvents if I would like to
receive events. This requires makepy registration, so I created an
idl-file for the server, compiled it with midl to a tlb file and
compiled this with makepy to a python file.

You probably need to tell your server about the typelib being associated with your server - eg, look at the win32com\test\pippo_server.py - it includes the following information in the class:

    ### Link to typelib
    _typelib_guid_ = '{41059C57-975F-4B36-8FF3-C5117426647A}'
    _typelib_version_ = 1, 0
    _com_interfaces_ = ['IPippo']

Obviously your ids will be different, but this should be enough to allow your server to provide the typeinfo when requested by Python, and therefore allow clients to use it.

HTH,

Mark

Now I thought everything should work. But it doesn't:

Z:\extension\test>testclient.py
<COMObject testproject.TestServer>
Traceback (most recent call last):
File "Z:\extension\test\testclient.py", line 28, in <module>
server = win32com.client.DispatchWithEvents("testproject.TestServer",
TestServerEventHandler)
File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line
256, in DispatchWithEvents
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please
run makepy manually for this object

(I've attached a simple example client and server including the file
generated by makepy)

Others seem to have similar problems
http://www.mail-archive.com/python-win32@python.org/msg02142.html
http://mail.python.org/pipermail/python-win32/2008-November/008384.html

but I can't find a solution. Is it impossible? If yes, is there another
way to connect a python client to a python com server with events?


-Ulrich



_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to