[python-win32] win32com + Excel + Django + Apache = problem
cricogik
cricogik at gmail.com
Wed Jan 26 19:51:35 CET 2011
> Does that user have access to that path?
Yes, apache has full access. It's problem in win32com, because when I add
before calling Workbooks.Open:
open("C:\\path\\to\\file.xlsx")
application won't crash, so apache can open/read/write this file. Also when
I running application under django developer server everything works.
I tested code on Apache 2.2 (mod_wsgi), py2.6, Windows 2008 Server (64 bit)
and Windows 7 (32 bit) .. the same result ;/
>I don't know much of anything about COM or multi-threading in Apache,
>but the error seems to indicate a permissions problem. What system user
>is Apache running under? Does that user have access to that path?
>Another option is to use "run as" to open a command prompt as the same
>system user that apache runs under. Once you get to that point, then
>run the Django developer server and see if what you are trying to do works.
>--------------------------------------
>Randy Syring
>Intelicom
>Direct: 502-276-0459
>Office: 502-212-9913
>
>For the wages of sin is death, but the
>free gift of God is eternal life in
>Christ Jesus our Lord (Rom 6:23)
>On 01/26/2011 09:09 AM, user wrote:
>>
>> Hello,
>>
>> I have some problems while opening Excel (via win32com) document in a
>> web application
>> running under Apache(mod_wsgi)/Windows 2008 Server (there is no
>> problem when the application is running on django developer server -
>> one thread).
>>
>> My code:
>>
>> def my_view(request):
>> import pythoncom
>> from win32com.client import DispatchEx
>>
>> pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
>> xl = win32com.client.dynamic.Dispatch('Excel.Application')
>> xl.DisplayAlerts = False
>> xl.Visible = 0
>> doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx")
>> doc.Saved = True
>> ...
>> doc.Close(SaveChanges=0)
>> xl.Quit()
>> pythoncom.CoUninitialize()
>>
>> Error message:
>>
>> (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel',
>> u"Microsoft Office Excel cannot access the file 'C:\\path\to\
>> \file.xlsx'. There are several possible reasons: The file name or path
>> does not exist. The file is being used by another program. The
>> workbook you are trying to save has the same name as a currently open
>> workbook.", u'C:\\Program Files (x86)\\Microsoft Office\\Office12\
>> \1033\\XLMAIN11.CHM', 0, -2146827284), None)
>>
>> I know that problem is localized somewhere in threading, but where?
>> I'm using pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED).
>> Maybe changing the server will solve the problem?
>>
>> Libs: Django 1.2, Apache 2.2 (mod_wsgi), win32com (latest)
>>
>> I hope somebody can help me.
>>
>> Thank You,
>> regards.
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110126/c78d2426/attachment.html>
More information about the python-win32
mailing list