Jorey Bump
list+mod_python at joreybump.com
Wed Apr 14 21:37:51 EST 2004
Jeff Hinrichs wrote: > ----- Original Message ----- > From: "Jorey Bump" <list+mod_python at joreybump.com> > >>For this reason, you should avoid setting your DirectoryIndex to a >>python module (index.py). Use a gateway index.html page, instead, or >>link directly to the python file. > > Could you explain what you mean by gateway index.html page? Something that > redirects requests to / to the proper module? An example would be a form-based application. Let's say you have a survey about snakes, and want people to go to: http://www.example.com/survey/ This would take them to a default page named index.html, which would simply be a form with the action set to: http://www.example.com/survey/snake.py/submit When someone submits the form, your module takes over, and returns a page that may contain links to other functions in snake.py. This allows you to keep your application's files in one directory, and distribute them easily to other mod_python installations (as long as they aren't already using another snake.py). But don't think index.py is evil. You could put a single index.py in the root of your site, and drive the entire thing from it. Then you could create a new module for each application, give it a unique name, and keep it in the root directory alongside index.py. Putting all of your modules in one directory will help you to avoid name clashes, and encourage you to reuse code. You could even put all of your modules in a directory in your PYTHONPATH, safely outside the DocumentRoot, and import them as needed. Each virtual host could have a directory appended to its PYTHONPATH and drive its entire site with index.py and any static files it might need, such as images. With simplicity comes enormous flexibility.
|