win32com: get error 80004005 in attempt to use a pythom COM s erver - found it!

LArbilla at pav.com LArbilla at pav.com
Wed Aug 8 11:27:17 EDT 2001


This problem has bugged me.  So, I went back and compared the changes
I made that made the whole thing work.  The culprits were:

a) _reg_class_spec is obsolete
			_reg_class_spec_ = "raecom.Rae"
b) __init__ must NOT have a return statement
				return 1

The use of "str" to convert from Unicode to Python was also an error, but
had nothing to do with the initialization of the server, just an error in
calling
that method.

FYI,
Laura.

> -----Original Message-----
> From:	Laura Arbilla 
> Sent:	Monday, August 06, 2001 2:55 PM
> To:	Laura Arbilla; 'python-list at python.org'
> Subject:	RE: win32com: get error 80004005 in attempt to use a pythom
> COM server - found it!
> 
> I found the problems:
> 1) I had a field, _pid, in class RAE, which I meant as private.  However
> it needed to be declared
> in _public_attrs_.  Is there a _private_attrs_ declaration ?
> 2) Also, the line:
> 			self._pid = raeapimodule.ConfigFromFile(fileName)
> needed to be changed to
> 			self._pid =
> raeapimodule.ConfigFromFile(str(fileName))
> to avoid an error converting between Unicode and Python strings.
> 
> FYI,
> Laura.
> 
> 
> 	-----Original Message-----
> 	From:	Laura Arbilla 
> 	Sent:	Monday, August 06, 2001 12:15 PM
> 	To:	'python-list at python.org'
> 	Subject:	win32com: get error 80004005 in attempt to use a
> pythom COM server
> 
> 	I'm seriously stuck (2 days now) at my first attempt to use win32com
> to write a com server in python.
> 	I've search and read all I could find and I still don't see how to
> solve the problem:
> 	  
> 	1) I wrote a simple COM server in python, it registers and I can see
> it in PythonWin's COM Browser:
> 	2) I tried to use it from VB:
> 		Dim theServer As Object
> 		Set theServer = CreateObject("Python.Rae")
> 	   and got error -2147467259 (80004005) "Unexpected Python Error:
> exceptions.ImportError: No module named raecom"
> 	3) So, I decided to first test it from Python.
> 	   The client calls the server's  __init__ (from
> win32com.client.Dispatch), 
> 	   but the call fails with the same error (in python, it only shows
> -2147467259)
> 	3) I tried:
> 		- putting all of the code in c:\program files\python  (where
> python and win32com are installed)
> 			and it didn't make a difference
> 		- I also tried commenting out the line "_reg_class_spec",
> which has the only reference to "raecom"
> 			and it didn't make a difference
> 
> 	I would appreciate any tips. I'm sure it is something simple.
> 	Below is the code for the server, the client and the "trace".
> 	Thanks a bunch!!
> 	Laura.
> 	larbilla at pav.com
> 
> 	SERVER CODE:
> 	import win32com.server
> 	import raeapimodule
> 	import win32traceutil
> 
> 	class Rae:
> 		_public_methods_ = ['ConfigFromFile', 'Init']
> 		_public_attrs_ = ['projectName']
> 		_readonly_attrs_ = ['projectName']
> 		_reg_clsid_ = "{8680B790-875A-11d5-9A59-005004630197}"
> 		_reg_progid_ = "Python.Rae"
> 		_reg_desc_ = "Python COM RAE Wrapper"
> 		_reg_class_spec_ = "raecom.Rae"
> 	#only for dual interfaces
> 	#	_com_interfaces_ = ['IRae']
> 		def __init__(self):
> 			print "raecomp.py.class Rae.__init__ being called"
> 			self._pid = -1
> 			print "raecomp.py.class Rae.__init__ uno"
> 			self.projectName = ""
> 			print "raecomp.py.class Rae.__init__ dos"
> 			return 1
> 		def ConfigFromFile(self, fileName):
> 			print "raecom.py.class Rae.ConfigFromFile being
> called"
> 			self._pid = raeapimodule.ConfigFromFile(fileName)
> 			if (self._pid > 0):
> 				self.projectName = fileName
> 			return self._pid
> 		def Init(self):
> 			print "raecom.py.class Rae.Init being called"
> 			status = raeapimodule.Init(self._pid)
> 			return status
> 
> 	if __name__ == '__main__':
> 		import win32com.server.register
> 		win32com.server.register.UseCommandLine(Rae)
> 
> 	CLIENT CODE:
> 
> 	import win32com.client
> 	print "start"
> 	o = win32com.client.Dispatch("Python.Rae")
> 	print "called dispatch"
> 	
> o.ConfigFromFile("c:\\larbilla\\test\\raetest\\pull_multimap_4.pi_ot_confi
> g")
> 	print "called configfromfile"
> 	print o.projectName
> 
> 	TRACEUTIL:
> 
> 	Registered: Python.Rae 
> 	start  <--- this actually shows in the command line
> 	raecomp.py.class Rae.__init__ being called
> 	raecomp.py.class Rae.__init__ uno
> 	raecomp.py.class Rae.__init__ dos
> 	Traceback (innermost last):
> 	  File "raecomtest.py", line 4, in ?
> 	    o = win32com.client.Dispatch("Python.Rae")
> 	  File "C:\Program Files\Python\win32com\client\__init__.py", line
> 94, in Dispatch
> 	    dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> 	  File "C:\Program Files\Python\win32com\client\dynamic.py", line
> 80, in _GetGoodDispatchAndUserName
> 	    return (_GetGoodDispatch(IDispatch, clsctx), userName)
> 	  File "C:\Program Files\Python\win32com\client\dynamic.py", line
> 71, in _GetGoodDispatch
> 	    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> 	pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)
> 
> 




More information about the Python-list mailing list