Exporting events from Python COM class.

Syver Enstad syver.enstad at sensewave.com
Fri Nov 10 20:59:50 EST 2000


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:8uecgq0217t at news1.newsguy.com...
> "Alex Martelli" <aleaxit at yahoo.com> wrote in message
> news:8ueb9l01voj at news1.newsguy.com...
>     [snip]
> > c. it sets its classmember _connect_interfaces_ to the list of
> >     IIDs for the event (aka 'source') interfaces it wants to
>     [snip]
> > Points e/f may be a little delicate in the very unusual case
> > in which you want your server to expose TWO source-interfaces --
>
> Oops -- I just checked win32com\server\connect.py, and this
> just won't fly -- the client-object trying to connect is
> always queried for the *first* interface in the list, so
> the others (if any) seem to be there just to cause confusion
> (when the client does the FindConnectionPoint for an IID
> that's in the list, but not the first one, it will appear
> to succeed -- but then the call to Advise will fail!).
Is this similar to the bug in IE5.0 HTMLDocument Advise implementation
where you try to  sink the events for DHTMLDocumentEvents2 but IE insists on
firing the events for DHTMLDocumentEvents on your object that implements
DHTMLDocumentEvents2 causing no end of grief?

> I also think there's a bug in win32com\server\connect.py's
> Advise implementation -- if a client tries to connect (to
> the one-and-only source interface), with an object that
> also implements some _other_ dispatch-interface (and
> returns that 'other' when QI's for IDispatch), the methods
> being called when events are fired are going to be methods
> on the _default_ IDispatch version of the client-object,
> NOT on the specific dispinterface it asked to connect.  I
> think this violates COM's rules, and, while it's unlikely
> that a specific client implementation will trigger this
> bug, I expect _very_ subtle, hard to reproduce, hard to
> understand, little semantics disasters if/when it happens.

You mean that if I implement f.ex a C++ object that implements two IDispatch
interfaces and one of them is a sink for a python implemented COM object,
Python will screw up and call the wrong Dispatch interface? (Like in the IE
example that I've lined up above?)

I must get the time some day to dive deeper into the Python implementation
of COM, fascinating stuff. Anyway, superb response Mark and Alex. I must say
the Python community is one of the most helpful (if not the most helpful)
I've ever seen.





More information about the Python-list mailing list