list at joreybump.com
Tue Oct 4 16:45:01 EDT 2005
Erdi Balint wrote: > Hi all, > > I've just tried my first publisher handler page with the following > configuration: > > <Directory /var/www/modpython_test> > Options -Multiviews > SetHandler python-program > PythonHandler mod_python.publisher > PythonDebug on > </Directory> > > If I have a bmath.html file in the /var/www/modpython_test directory, > than I get a 404 trying to query it (and any other file in this > directory, be it html or py script!). However, if I move this bmath.html > file to /var/www then everything works well, and I can even reach my > handler script basic_math.py sitting in /var/www/modpython_test like this: > > <form action="modpython_test/basic_math/add" > > .... > > I've searched in the archives, but have only found: > > "If mod_python picks the wrong module to import, a number of possible > faulures can happen, depending on subtlties of the configuration and the > nature of the module. You might get a blank page, or you might get the > text of the actual script dumped, or you might get an exception, or you > might get a 404." > > But here it is only a plain html file that needs to be fetched, so no > module needs to be imported or anything. Why can't I put it into the > modpython_test directory? The SetHandler directive causes *all* files in the directory to be handled by mod_python. If you want to mix files in a directory, use AddHandler with an extension, instead: <Directory /var/www/modpython_test> Options -Multiviews AddHandler python-program .py PythonHandler mod_python.publisher PythonDebug on </Directory> Or you can get tricky and use FilesMatch: <FilesMatch "someuniquename|anotheruniquename"> SetHandler python-program PythonHandler mod_python.publisher </FilesMatch> With AddHandler, you must specify the extension: <form action="modpython_test/basic_math.py/add"> With the FilesMatch hack, you can leave off the extension (as with SetHandler), but you must be very careful that there are no other matches for the unique string you use. It becomes sort of a "registry" for your Published modules, and adds a little work to administration. I do use it on some production machines, however, and it works fine. FWIW, I prefer to use SetHandler, putting all publisher modules in a single directory and storing other types of resources elsewhere.