Problem setting COM property using win32com
Paul Prescod
paul at prescod.net
Mon Apr 7 18:41:55 EDT 2003
Bare in mind that I'm not a COM expert. We should probably be talking
about this on the python-win32 list. But I see something strange in your
makepy code...
Green, Gregory P wrote:
>
> # This CoClass is known by the name 'SmRecList.SmRecordList'
> class SmRecordList(CoClassBaseClass): # A CoClass
> # An object used for storing data. A collection of headers and records, each composed of a collection of nodes. In turn, each node can contain information of various types.
> CLSID = pythoncom.MakeIID("{C85E7014-8B4F-11D1-8E20-00A02498EA3C}")
> coclass_sources = [
> ]
> coclass_interfaces = [
> '{C85E7013-8B4F-11D1-8E20-00A02498EA3C}',
> '{C85E7015-8B4F-11D1-8E20-00A02498EA3C}',
> ]
> default_interface = '{C85E7013-8B4F-11D1-8E20-00A02498EA3C}'
In my makepy'd classes, default_interface is never a string.
class ResourceManager(CoClassBaseClass): # A CoClass
# ResourceManager Class
... default_interface = _ResourceManager
# This CoClass is known by the name 'XMetaL.Global'
class Global(CoClassBaseClass): # A CoClass
....
default_interface = _Global
That's probably why you're getting the "cannot call string" problem.
Look at the __init__ that's causing a problem. It probably looks like this:
class CoClassBaseClass:
def __init__(self, oobj=None):
if oobj is None: oobj = pythoncom.new(self.CLSID)
self.__dict__["_dispobj_"]=self.default_interface(oobj)
I don't know how your default_interface got to be a string (perhaps a
genpy bug, or hand-tweaking, or something else I don't understand), but
I'd suggest you replace it with something like:
default_interface = _SmRecordList
or maybe
default_interface = ISmRecordList
Paul Prescod
More information about the Python-list
mailing list