[mod_python] .pyc and .pyo bytecode files under mod_python ?

Dustin Mitchell dustin at ywlcs.org
Wed Feb 20 16:26:15 EST 2002

On Wed, Feb 20, 2002 at 01:00:13PM -0800, mike at mikebell.org wrote:
> .pyc files should be created automatically, all you need to do is insure
> that the directory from which your mod_python scripts are being run is
> writable to your web server, otherwise it cannot create the .pyc files.
> Setting PythonOptimize to on will result in the creation of .pyo files.

Be **very** careful if you do this -- the security implications of allowing
write access to your source files are pretty enormous.  For example, if
someone can write a file to your system (perhaps through a bug in a
file-upload system?), they can upload their own program to do whatever damage
they would like.

My approach to .pyo/c files has been to run a short script that uses the
Python compile module to compile all of the source files in the site.  Since
I run the script as me (not as the user running the web server) all of the
.pyo/c files are owned by me and not writeable by the web server.

My $0.02.



  Dustin Mitchell
  dustin at ywlcs.org

More information about the Mod_python mailing list