[python-win32] Dispatches With Events on COM Object
Neil Benn
benn at cenix-bioscience.com
Tue Aug 8 11:08:52 CEST 2006
Mark Hammond wrote:
>> 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"
> <snip>
>
Hello,
Thanks for your reply, I put logging onto the screen and here
is what I found:
* The call to Dispatch happens
* The __wrapDispatch is called with an object for dispatch but the
username is None
* The getTypeInfo method throws an pywintypes.com_error which has
the message of (-2147467263, 'Not implemented', None, None)
* The dynamic dispatch method is called which returns an instance of
COMObject
* the __class__.__dict__ for this has the following key/value pairs
0 = _wrap_dispatch_
1 = __module__
2 = __doc__
Therefore there is no CLSID for the object which causes the makepy
message to appear. I've printed out the return from the dynamic
dispatch call:
DISPATCH PRINT
<COMObject <unknown>>
DIR DISPATCH PRINT
['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum',
'_Release_', '__A
ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__',
'__getattr__', '__g
etitem__', '__init__', '__int__', '__len__', '__module__',
'__nonzero__', '__rep
r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_',
'_enum_', '_fin
d_dispatch_type_', '_get_good_object_', '_get_good_single_object_',
'_lazydata_'
, '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_',
'_print_details_
', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']
DISPATCH MAP
0 = _wrap_dispatch_
1 = __module__
2 = __doc__
Is there anything there which could provide a clue?
Cheers,
Neil
--
Neil Benn MSc
Head of Automation
Cenix BioScience GmbH
Tatzberg 47
01307 Dresden
Germany
http://wwww.cenix-bioscience.com
More information about the Python-win32
mailing list