[python-win32] Cannot get COM early bound

Mark Hammond mhammond at skippinet.com.au
Thu May 17 04:51:38 CEST 2007


> Greetings,
>
> I have been a COM expert for all of two days ;-)
>
> I did get a Type Mismatch error on an argument, .. the more I dug and
> researched this error, the more I found out and now have a question
> about early binding.
>
> I am trying to get access to two COM objects/interfaces <=(don't know
> what word to use here, so bear with me if I get it wrong)
>
> The COM objects I'm interested in are ClearCase Automation
> Library (CAL)
> & ClearQuestOLEServer
>
> I ran makepy on both of these.
> selected info from each of the generated files is
> ===============================
> # From type library 'ccauto.dll'
> # On Wed May 16 16:38:12 2007
> """ClearCase Automation Library 6.0"""
> makepy_version = '0.4.95'
> python_version = 0x20500f0
>  ::         ::
> # This CoClass is known by the name 'ClearCase.Application.1'
> class Application(CoClassBaseClass): # A CoClass
> ===============================
> # From type library 'cqole.dll'
> # On Wed May 16 16:37:15 2007
> """"""
> makepy_version = '0.4.95'
> python_version = 0x20500f0
>  ::         ::
> # This CoClass is known by the name 'CLEARQUEST.SESSION'
> class Session(CoClassBaseClass): # A CoClass
> ===============================
>
> Chapter 12 of Marks book, indicates case sensitivity can be a problem
> for late bound
> Also VARIANT translations may not work so well under late bound.
>
> I wanted to use early bound to ensure my VARIANTS are correct. But I
> cannot get the
> CLEARQUEST.SESSION early bound. I successfully got
> ClearCase.Application
> early bound
>
> The output of my program indicates that the
> ClearCase.Application object
> was early bound, but I
> could do nothing to get CLEARQUEST.SESSION early bound

Sadly some objects behave like this - they provide a typelib, but when you
ask the object itself about the type info, it says it has none!  win32com is
therefore unable to associate the object with the makepy module.

The "standard" answer here is to force things.  Something like:

mod = gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}' , 0, 1,
0)
cq_session = w32c.Dispatch(r"CLEARQUEST.SESSION")
cq_session = mod.Session(cq_session)

This should force cq_session to use the makepy generated info.  You may even
find:

mod = gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}' , 0, 1,
0)
cq_session = mod.Session()

works, but I can't recall...

Hope this helps,

Mark



More information about the Python-win32 mailing list