[mod_python] writing to a file from mod_python

tpc at csua.berkeley.edu tpc at csua.berkeley.edu
Tue Sep 30 13:37:46 EST 2003


hello all I have the following script that ran fine from the command line:

<code>
#!/usr/bin/env python

#string1 = "hello world!"

def writeFile(string1):
        open('somefile.txt', 'w').write(string1)

## writeFile(string1)
</code>

but as soon as I ported it to mod python I got the following:

<paste>
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 335, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line 194, in handler
    result = apply(object, (), args)

  File "/var/www/html/python/testing.py", line 7, in writeFile

IOError: [Errno 13] Permission denied: 'somefile.txt'
</paste>

I searched the web for the error message, chmod'ed 777 somefile.txt, and
even chown'ed and chgrp'ed to user and group apache, all to no avail.  Is
there a way to write to a file from mod python ?



More information about the Mod_python mailing list