COM/IIS permissions question

Lawrence Hudson lawrence at quicklizard.com
Wed Nov 17 07:28:08 EST 2004


Andrew Burton wrote:

> Anyone know where else I can find instructions for "Launching OLE Servers
> from ISAPI Extensions"(1). I followed those instructions, even went so far
> as to give a few other accounts permission, but my Python -- that's Python
> 2.2 -- script keeps given me the following error:
> 
> [error]
> 
> Traceback (most recent call last):
>   File "D:\JAROD\programming\python\pycgitunes\pycgitunes.py", line 12, in
>   ?
>     iTunes = win32com.client.Dispatch("iTunes.Application")
>   File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
>   92, in
> Dispatch
>     dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
>   File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line
>   81, in
> _GetGoodDispatchAndUserName
>     return (_GetGoodDispatch(IDispatch, clsctx), userName)
>   File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line
>   72, in
> _GetGoodDispatch
>     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)
> 
> [/error]
> 
> Here's the code I'm using, in case anyone's curious -- this is my first,
> REAL Python program, so maybe it's just a glitch. Hoever, a thread from
> mail.python.org's archives(2) and the fact that it works from an
> Interactive shell makes me think that the ISAPI/COM security problem is
> the key. Anyway, code...
> 
> [code]
> 
> # Libraries
> import cgi
> import cgitb
> import win32com.client
> 
> # COM stuff
> iTunes = win32com.client.Dispatch("iTunes.Application")
> 
> # global variables
> form = cgi.FieldStorage()
> 
> #####
> # Subroutines
> 
> # main code
> cgitb.enable()
> 
> print "Content-type: text/html\n\n"
> print "Hello, world"
> 
> [/code]
> 
> Any help would be appreciated -- any IIS/Python tips especially. Thanks!
> 
> ---
> 
> 1. http://support.microsoft.com/kb/q156223/
> 
> 2. http://mail.python.org/pipermail/python-list/1999-November/015411.html
> 
> Andrew Burton - tuglyraisin at aol dot com
> Felecia Station on Harvestgain - Jarod Godel in Second Life
Its been a while since I did this sort of stuff but you need initialise COM
before using any COM facilities. Something like:

import pythoncom
pythoncom.OleInitialize()

Lawrence




More information about the Python-list mailing list