The COM example has started lots of us on the way..
[
o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"
]
Is there a similar example for DCOM
(say to a server "Python.Test" on machine IP a.b.c.d)
cheers
and thanks
chris
The simple answer is "no".
The medium answer is "Python just works".
The long answer is typical:
DCOM is faily complex, with some new concepts. Using DCOM, it is
possible to setup COM objects to use DCOM, but the client never knows.
The client just creates a COM object locally, but the magic of COM
redirects this to another machine.
At the other end of the scale, DCOM gives enough flexibility so that the
client can control if the server is created: locally via a .exe, locally
via a .dll, locally via an NT service, remotely via an EXE, and remotely
via a service. Any or all of these models can be supported. A specific
COM object can register itself as supporting any or all of these
mechanisms (this is the "CLSCTX" flag that no one ever sees :-) The
client can use any of these modes specifically, or let COM choose. Then
there is CoCreateInstanceEx(), which Pythoncom exposes. This allows the
Python programmer to specify the machine to create the instance on.
If you setup the COM object appropriately, it should work without any
changes at all. However, if you want the additional flexibility, then
you need to do a little more work. Eg, win32com.client.Dispatch is
psuedo-coded below:
dispatch = pythoncom.CoCreateInstance(progid, CLSCTX_SERVER,
IID_IDispatch)
return win32com.client.dynamic.Dispatch(dispatch)
You would need to duplicate this, but specify the different params to
CoCreateInstanceEx. After that, it just works as normal.
It is possible that this could be wrapped in the same way that
win32com.client.Dispatch does. However, once you get into that
territory, you need to know what you are doing - eg, the CLSCTX flag has
far more implications, there are special functions for getting many
interfaces at once to reduce network bottlenecks, etc. So Im not sure
this is desirable.
And just to add one more piece of confusion to the pot, the COM Servers
must be registered on both the remote and local machine. This means the
local machine registration must be performed, even though the software
may not be installed.
So, back to your original question: No, there is not. It is hard to
do.
However, I can offer this. I would be willing to turn the
"Python.Interpreter" COM sample into a DCOM demo. This would involve
minor changes, but mainly documentation on how to set it all up, on both
the client and the server. If someone is willing to help with this....
Mark.