python file permisions
John J. Lee
jjl at pobox.com
Wed May 21 08:55:36 EDT 2003
balgorg at hotmail.com (Brett Irving) writes:
[...]
> def AddUser(username,userdata):
> users_db = dumbdbm.open('../dbase/mydumbdbm')
> os.system("chmod 777 ../dbase/mydumbdbm.*")
> users_db[username] = userdata
> users_db.close()
> os.system("chmod 777 ../dir/dir/*")
>
> If the database is not there it gets created and then chmoded to 777
> but its not letting me do that and keeps appearing with 500 server
> error
>
> log file error: IOError: [Errno 13] Permission denied:
> '../dbase/mydumbdbm.dat'
>
> If somebody could tell me how to set file permissions when I am
> creating files it would be greatly appreciated.
This isn't a Python problem -- your server is probably running as a
non-privelidged user, so doesn't have permission to do what you want.
BTW, os.chmod (surprise!) is better than calling os.system (see
section 6.1.4 of library manual). Faster and more portable than
creating a subshell with os.system.
John
More information about the Python-list
mailing list