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

Åsmund Hjulstad asmund.hjulstad at gmail.com
Tue Nov 16 09:49:06 CET 2010


2010/11/9 Åsmund Hjulstad <asmund.hjulstad at gmail.com>:
> I am struggling with secondary interfaces and makepy
>
> I have generated an interface with makepy from a library ( PISDKCommon
> 1.0 Type Library ). It has an object, PIAsynchStatus, that exposes a
> secondary interface; IPIAsynchStatus2. I cannot find the secondary
> interface in the generated module, though. I wanted to do something
> like Mark Hammond suggested here:
> http://code.activestate.com/lists/python-list/27760/
>
> .. but without the secondary interface, I don't know how to do it.
>
> module = gencache.GetModuleForProgID('PISDKCommon.PIAsynchStatus')
> module.IPIAsynchStatus2   # Throws AttributeError

I am guessing the problem is that the library does not declare that the
any classes implement these secondary interfaces.

I have generated an IDL using the OLE/COM Object Viewer, where I see
for example

    [
      odl,
      uuid(6F8B6B6B-6232-458B-8783-7F73B98CDDC8),
      helpstring("Extended data operations for a PIPoint"),
      helpcontext(0x0000348a),
      dual,
      nonextensible,
      oleautomation
    ]
< several methods omitted >
    interface IPIData2 : _PIData {
        [id(0x00000066), helpstring("Return interoplated values from
the archive as a PIValues collection."), helpcontext(0x0000348d)]
        HRESULT InterpolatedValues2(
                        [in] VARIANT StartTime,
                        [in] VARIANT EndTime,
                        [in] VARIANT SampleInterval,
                        [in, optional, defaultvalue("")] BSTR filterExp,
                        [in, optional, defaultvalue(0)]
FilteredViewConstants ShowFiltered,
                        [in, optional, defaultvalue(0)]
_PIAsynchStatus* asynchStatus,
                        [out, retval] _PIValues** ret);
< several methods omitted >
}

but the class definition

    [
      uuid(34B81AB1-F39B-11D2-BD71-00C04F779EB2),
      helpstring("This object accesses snapshot/archive data for a PIPoint"),
      noncreatable
    ]
    coclass PIData {
        [default] interface _PIData;
    };

does not declare that it implements IPIData2. And, possibly because of this,
makepy never creates the proper early-bound interfaces for the IPIData2
interface.

So, is there a way to force makepy (or gencache) to generate the interface?
(or even better, to change the default interface of the returned objects)

I have switched to late-bound invocation for now, and it works fine, but I
would very much like to get early-bound working as it is much more elegant
to work with in ipython.


More information about the python-win32 mailing list