[mod_python] Problem writing to file from handler

oddmund.mogedal at accenture.com oddmund.mogedal at accenture.com
Tue Jan 30 20:36:08 EST 2001


Hi,

I need to write to a file from within a script (called using publisher.py).
For some reason, I am not allowed to write to the file, even though it
exists and has write permission for everyone.
(Yes, it is a security risk, but not in the environment where I will use
it.)

I have tried the same thing using the cgi module, and then I am allowed to
write to the file.
Is there a difference in access rights to the file system between a script
called from mod_python and a script called using CGI?

Does anybody know what is causing this problem?

Using mod_python: DOES NOT WORK
    import getpass

    def omtest(req, username, file):
        myfile = open("testom", 'wb')
        myfile.write(file)
        myfile.close()
        return "%s\n%d\n%s\n" % (username, len(file), getpass.getuser())

Using cgi: WORKS OK
    #!/usr/local/bin/python2.0

    import getpass
    import sys
    import cgi

    myfile = open("testom", 'wb')
    form = cgi.FieldStorage()
    name = form["name"].value
    file = form["file"].value
    myfile.write(file)

    print "Content-Type: text/html"
    print
    print name
    print getpass.getuser()




Oddmund



This message is for the designated recipient only and may contain
privileged or confidential information.  If you have received it in error,
please notify the sender immediately and delete the original.  Any other
use of the email by you is prohibited.





More information about the Mod_python mailing list