can't write to file in mod_wsgi app: permission denied
I have a ver开发者_如何学JAVAy simple mod_wsgi python application that tries to write to a file:
tempfile = open('temp.txt', 'w')
This fails with
IOError: [Errno 13] Permission denied: 'temp.txt'
The folder with myapp.wsgi has world-writable permissions (777). I can write to a file from a simple PHP test script. This is running on Mac OSX 10.6 Snow Leopard, so as far as I know, there are no additional protection mechanisms in place (SELinux, AppArmor, etc.).
Why are write permissions denied ?
Yep, the solution to the problem is to use full paths to spcify file locations (and, just to be on the safe side, to specify shell commands you might be using in system call (or popen) calls), as the $PATH might not be what you expect it).
精彩评论