[mod_python] Mod_Python and win32com

David Fraser davidf at sjsoft.com
Thu Feb 12 09:10:57 EST 2004


Glad to hear that, I was really stumped as to what the problem could be...

David

Ryan Felder wrote:

>Okay, I've got my problem solved. The trouble was that the com
>object I was polling for data was getting it from a running application.
>Due to the default permissions enforced upon Apache by windows, this
>behaviour
>is restricted. The solution, I found, was to modify my Apache service's
>properties, and set the "Allow service to interact with the desktop" check.
>
>
>
>-----Original Message-----
>From: David Fraser [mailto:davidf at sjsoft.com]
>Sent: Tuesday, February 10, 2004 1:04 AM
>To: Ryan Felder
>Cc: mod_python at modpython.org
>Subject: Re: [mod_python] Mod_Python and win32com
>
>
>Ryan Felder wrote:
>
>  
>
>>Hi all, I'm pretty new to working with Mod_Python, and the project I am
>>working on requires me to be able to poll for some data through COM.
>>
>>I am developing in windows 2000 professional, and will be running
>>my code on windows apache 2.0 with mod python. More specifically,
>>I am using the distribution of apache ssl and others named Swamp.
>>
>>The code works fine when I run it standalone, however, when I attempt
>>to run it on my development site, the calls to the com object that work
>>beautifully alone, simply fail to return data. As follows is a brief
>>code sample which demonstrates this behaviour. This code functions
>>properly from a command prompt or in the interpreter.
>>
>>def index():
>>	import win32com.client
>>	a=win32com.client.Dispatch('MyDataSource')
>>	b=str(a.GetOrders(account_identifier,'',2,0))
>>	return str(len(b))
>>
>>if __name__ == "__main__":
>>	print index()
>>
>>When this code runs standalone, it will return a non-zero value,
>>and when run from mod_python, it returns a zero value, due to
>>the len() function measuring the length of the output of my data call.
>>
>>By way of typos, I have been able to produce exceptions in my testing
>>browser, so this leads me to believe that it is not passing any exceptions.
>>
>>My research online has suggested that I try importing my modules through
>>apache.import_module. This gives me a number of different issues where
>>if I instantiate an instance of win32com, then try to address
>>that.client.Dispatch,
>>I recieve "module does not have 'client'", or similarly, if I try to
>>instantiate
>>an instance of win32com.client, I recieve "module does not have
>>    
>>
>'Dispatch'".
>  
>
>>I have also seen it suggested that I initialize the com properly, and
>>manually,
>>by
>>	import sys
>>	sys.coinit_flags = 0
>>
>>as well as
>>
>>	import pythoncom
>>	pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
>>
>>which I do before attemting to import win32com, but to no avail,
>>in many, and in all permutations.
>>
>>I have tried every permutation of apache.import_module and import,
>>that I can muster, and I am hitting a brick wall.
>>
>>It seems that there is a breakdown in communications between myself and the
>>com objects when I try to import them. Any help that you all can offer me
>>would be hugely appreciated!
>>
>>- Ryan
>>
>>
>>    
>>
>This sounds wierd
>We use win32com.client without any problems from within mod_python (also
>using similar versions to you, but Python 2.2).
>Which version of win32all are you using? It may be interesting to try
>stepping into the win32com code and adding traces, to see whether the
>COM call is actually made and nothing is returned, or whether it never
>gets there and isn't producing an error though it should be.
>
>David
>
>
>  
>



More information about the Mod_python mailing list