Python COM: Unable to create server-side object.
Bill Bell
bill-bell at bill-bell.hamilton.on.ca
Thu Jun 21 17:29:58 EDT 2001
arisen at start.no (André) wrote:
> Hi. Something strange is happening to in my Python / COM
> recently (ActiveState Python 2.0 on Win2K). I have created
> this small class in the file short.py:
>
> class Short:
> _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}"
> _reg_progid_ = "Python.Short"
> _reg_desc_ = "PythonCOM test"
> _public_methods = ["isShort"]
>
> def __init__(self):
> self.short = "yes"
>
> def isShort(self):
> return self.short
>
> if __name__=="__main__":
> import win32com.server.register
> win32com.server.register.UseCommandLine(Short)
>
> And registered it succcessfully. ($ python short.py)
>
> When i try
> >>> import win32com.client
> >>> s = win32com.client.Dispatch("Python.Short")
>
> I get the following error:
> (-2147221231, 'ClassFactory cannot supply requested class', None,
> None)
>
> If i try it again i get another:
> (-2147467259, 'Unspecified error', None, None)
>
> I have tried with diffeetn class names, prog ids and clsids.
>
> This used to work fine, and i have written several com servers
> in python before which still work. Any ideas?
André,
I added debugging to your code in the following way:
debugging = 1
class Short:
_reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}"
_reg_progid_ = "Python.Short"
_reg_desc_ = "PythonCOM test"
_public_methods = ["isShort"]
def __init__(self):
self.short = "yes"
def isShort(self):
return self.short
if __name__=="__main__":
import win32com.server.register
win32com.server.register.UseCommandLine(Short,
debug=debugging)
This gives the following diagnostic output in the "win32trace remote
collector".
Object with win32trace dispatcher created (object=None)
Traceback (most recent call last):
File "c:\python21\win32com\server\dispatcher.py", line 27, in _CreateInstance_
self.policy._CreateInstance_(clsid, reqIID)
File "c:\python21\win32com\server\policy.py", line 200, in _CreateInstance_
self._wrap_(myob)
File "c:\python21\win32com\server\policy.py", line 448, in _wrap_
raise error, "Object does not support DesignatedWrapPolicy"
win32com.server.policy error: Object does not support DesignatedWrapPolicy
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "c:\python21\win32com\client\__init__.py", line 94, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "c:\python21\win32com\client\dynamic.py", line 81, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "c:\python21\win32com\client\dynamic.py", line 72, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147467259, 'Unspecified error', None, None)
Any use to you? (Incidentally, I did this in Win95 with newly
installed ActiveState distribution, installed this morning.)
Bill
More information about the Python-list
mailing list