[python-win32] Returning IDispatch from a COM server method

Juan Carlos CORUŅA jcoruna@ibdosnorte.com
Mon, 12 Aug 2002 19:57:35 +0200


Hi all!

I'm trying to develop two COM servers in python and a method of one of
them must return a instance of the other COM server. The method is:

    interface IBusAdapter : IDispatch {
        ....
        [id(1005), helpstring("method CreateoutMessage")]
            HRESULT CreateoutMessage([out, retval] IDispatch
**pIOutMessage);
        ....
    };


This is the OutMessage COM object:

    interface IOutMessage : IDispatch {
        ....
        [id(1001), helpstring("method Send")]
            HRESULT Send([in]long TimeOut, [out,retval] VARIANT_BOOL
*Sent);
        ....
    };

The two objects are coded in the same python module:

class BusAdapter:
        ....
	def CreateoutMessage(self, group):
		"""method CreateoutMessage"""
		om = OutMessage()
		return win32com.server.util.wrap(om)

class OutMessage:
        ....
	def Send(self, TimeOut):
        ....

As you can see I have tried wrapping the OutMessage instance without
success.

Can anyone explain me the way to return a COM server within the method
of another COM server?


Thanks.

Juan Carlos Coruņa

jcoruna@ibdosnorte.com