Problem setting COM property using win32com

Green, Gregory P gregory.p.green at boeing.com
Tue Apr 8 20:39:04 EDT 2003


The suggestion of replacing default_interface with the class name worked. At least I didn't get an error. I immediately ran into the same sort of problem (AttributeNotFound) with another object of another class. If I can solve that the same way, then I can verify that it worked for sure.

-----Original Message-----
From: Paul Prescod [mailto:paul at prescod.net]
Sent: Monday, April 07, 2003 3:42 PM
To: Green, Gregory P; python-list at python.org
Subject: Re: Problem setting COM property using win32com


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