[python-win32] Dispatches With Events on COM Object

Mark Hammond mhammond at skippinet.com.au
Sat Aug 5 03:56:43 CEST 2006


> Ah good point, I put back in the brackets (doh!) and I am now back to
> the previous place:
>
> mod =
> gencache.EnsureModule('{A4818FD5-6479-11D4-8452-00104B92DD56}', 0,
> 1, 0)
> print dir(mod)
> ob = mod.Application()
> print dir(ob)
> objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents)
>
>  >>> ['Application', 'CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap',
> 'CoClassBaseClass', 'Dispatch', 'DispatchBaseClass', 'IApplication',
> 'IApplicationEvents', 'IApplicationEvents_vtables_',
> 'IApplicationEvents_vtables_dispatch_', 'IDocumentEvents',
> 'IDocumentEvents_vtables_',
> 'IDocumentEvents_vtables_dispatch_', 'IID',
> 'LCID', 'LibraryFlags', 'MajorVersion', 'MinorVersion',
> 'NamesToIIDMap',
> 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap',
> '__builtins__',
> '__doc__', '__file__', '__name__', '_in_gencache_',
> 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg',
> 'makepy_version', 'python_version', 'pythoncom', 'win32com']
> ['CLSID', '__doc__', '__getattr__', '__init__', '__module__',
> '__repr__', '__setattr__', '_dispobj_', 'coclass_interfaces',
> 'coclass_sources', 'default_interface', 'default_source']
> Traceback (most recent call last):
>   File "C:\Program
> Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scr
> iptutils.py",
> line 310, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\Documents and Settings\benn\Desktop\cybio
> test.py", line 16, in ?
>     objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents)
>   File "C:\Program
> Files\Python24\Lib\site-packages\win32com\client\__init__.py",
>  line 254,
> in DispatchWithEvents
>     raise TypeError, "This COM object can not automate the makepy
> process - please run makepy manually for this object"
> TypeError: This COM object can not automate the makepy
> process - please
> run makepy manually for this object

That surprises me, and sadly I can't think of a reasonable COM object I can
use to help test this with.  Note the offending code in __init__.py:

  if not disp.__class__.__dict__.get("CLSID"): # Eeek - no makepy support -
try and build it.
    try:
      ...
    except pythoncom.com_error:
      raise TypeError, "This COM object can not automate the makepy
process - please run makepy manually for this object"

I'm expecting that first if statement to cause the entire block to be
skipped.  Indeed, 'CLSID' is one of the attributes in that list printed
above.  You may like to try and see if you can workout why we are entering
that block.

Cheers,

Mark



More information about the Python-win32 mailing list