win32com extension help

Peter Sparago psparago at yahoo.com
Sun Oct 17 19:00:14 CEST 2004


(Sorry in advance for the long post.)

Hi,

I'm having a great deal of difficulty buiding a Python COM extension.
I am using the MSHTML ActiveX control in my application but I need to
interact with and implement some Custom COM interfaces. All is well
with the basic operation of the control using Python.

Basically, I want to take over the right-click (context) menu from
MSHTML. To do this (to the best of my knowledge), you must request the
ICustomDoc interface from the control and set up your own
implementation of the IDocHostUIHandler interface. In Python COM
extension lingo, I need an ICustomDoc interface and an
IDocHOstUIHandler gateway.

First off, any link to HOW-TO documentation on this subject would be
greatly appreciated.

I wanted to start with something very simple, so I am trying to
implement an extension that understands only the ICustomDoc interface.
I ran makegw and hand-edited the resulting interfaces to get my .PYD
to compile and link (and even load!).

I pretty much understand the actual implementation of the COM support
generated by makegw, but I'm very hazy on the extension "wiring"
necessary to publish this COM support to Python. (i.e. the use of
PyMethodDef and PyCom_InterfaceSupportInfo etc.)

So, I thought I'd look for a working example and do a knock-off. I'm
running Python 2.3 and I've downloaded and built pywin32-203. I have
previously worked in great detail with the IFilter interface, so I
chose that win32comext project to use as a model. The problem is, when
I run the demo python code (called filterDemo.py) to exercise the
IFilter support, it fails with the following error:

C:\Joey\pywin32-203\com\win32comext\ifilter\demo>filterDemo.py
test.txt
Traceback (most recent call last):
  File "C:\Joey\pywin32-203\com\win32comext\ifilter\demo\filterDemo.py",
line 4,
 in ?
    from win32com.ifilter import ifilter
ImportError: cannot import name ifilter

This is the same error I'm getting with my own implementation .PYD.

(BTW: Yes, I have moved ifilter.pyd into the
C:\Python23\Lib\site-packages\win32com directory.)

Can ANYONE help? Please?



More information about the Python-list mailing list