[python-win32] Makepy does not generate all secondary interfaces?

Mark Hammond skippy.hammond at gmail.com
Wed Nov 17 04:43:08 CET 2010


On 16/11/2010 7:49 PM, Åsmund Hjulstad wrote:
> I am guessing the problem is that the library does not declare that the
> any classes implement these secondary interfaces.

It should iterate over every interface in the .idl file - see 
BuildOleItemsFromType in genpy.py (and maybe some "print debugging" in 
that file will help you see what is going on)

> So, is there a way to force makepy (or gencache) to generate the interface?

Nope - as it shouldn't skip them in the first place.

> (or even better, to change the default interface of the returned objects)

win32com will help you a little here - assuming the interface is 
generated, you could say something like:

mod = win32com.gencache.EnsureModule(...)
obj = win32com.client.Dispatch(...) # get default interface.
obj = mod.SomeOtherInterface(ob) # convert to SomeOtherInterface

This works due to the __init__ method generated for the interfaces (it 
does a QI - see the generated code for details)

HTH,

Mark


More information about the python-win32 mailing list