Assing a COM Interface to a Python object for callbacks

Alan Kennedy alanmk at hotmail.com
Thu Jul 3 08:28:56 EDT 2003


Mikko Ohtamaa wrote:

> I have a following problem:
> I am trying to do XML Schema validation using MSXML SAX parser through
> PythonCOM API.
> 
> MSXML offers two different interfaces for SAX: One for VB and one for
> C++. C++ one is named ISAXXMLReader and VB one is named
> IVBSAXXMLReader. I haven't found what is the basic difference between
> these interfaces though I have carefully read MSXML SDK documentation.
> I assume IVBSAXXMLReader might have some IDispatch functionality which
> is requirement for PythonCom(?).
> 
> The problem is that SAX Parser requires COM interface for callback.
> You must assign a COM interface as a handler to the parser. When the
> parsing begins, the handler calls this interface.
> 
> saxReader.errorHandler = myErrorHandler <-- COM Interface
> 
> I do not know how to turn Python class into COM interface on the fly.

I'm not sure how Mark Hammond's Windows extensions handle this
situation, if at all.

But I do know that Thomas Heller's "ctypes" has a COM framework which
addresses the problem. Only thing is, I don't know how robust the
current support is, given that, in Thomas own words: "Warning: work in
progress".

http://starship.python.net/crew/theller/ctypes/sum_sample.html

HTH,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list