Nicolas Lehuen
nicolas.lehuen at gmail.com
Thu Oct 6 14:35:06 EDT 2005
Hi Ken, Unfortunately for a lot of mod_python beginners, it is not clear why the mptest handler CANNOT be used directly by the publisher handler. First of all, try to have the publisher running as described here : http://www.modpython.org/live/current/doc-html/tut-pub.html Then, you'll understand that even if the publisher is correctly configured, if you call /mod_python/mptest.py, then the publisher handler will find the mptest module but NOT an index(req) function inside... You'll have to call /mod_python/mptest.py/handler to specify the function to call (or rename handler to index) and begin to solve your 404 problem. Last, but not least, handlers are supposed to write on the request object and return a status value (hence the return apache.OK), whereas the return value of published functions is the data you want to send back to the client (though you can also write on the request object to make things more interesting). To sum up, handlers are the lowest API of mod_python, and the publisher is just a handler which has its own system for publishing, which somewhat resembles the handler system, but with enough differences to prevent the two from being swappable at will... We know it's quite confusing for a newbie, but now that there are users for the two layers, we can't unify them :). Regards, Nicolas 2005/10/6, Ken Bradshaw <bradshak at us.ibm.com>: > > > Hello All, > I've recently taken an interest in python and mod_python in particular. For > the past two years or so I've been developing enterprise web apps in j2ee > with WebSphere Applications Server and Portal Server, so I'm pretty used to > pouring over documentation when configuration issues arise. Unfortunately, I > haven't found a solution to my problem regarding the PythonHandler > mod_python.publisher. Here's a brief synopsis of my environment and problem. > > Environment: > > I just used the standard packages provided by apt-get. > > Debian 3.1 stable > apache 2.0.54 > mod_python 3.1.3 > Python 2.3.5 > > Configuration: > > file: /etc/apache2/sites-available/default > > <Directory /var/www/mod_python> > AllowOverride FileInfo > </Directory> > > --for whatever reason I had to add this to get the .htaccess to work. > > file: /var/www/mod_python/.htaccess > > AddHandler python-program .py .psp > PythonHandler mptest > #PythonHandler mod_python.publisher | .py > PythonHandler mod_python.psp | .psp > PythonDebug On > > file: /var/www/mod_python/mptest.py > > from mod_python import apache > > def handler(req): > req.content_type="text/html" > req.write("<html><body>") > req.write("Hello World!") > req.write("</body></html>") > return apache.OK > > Problem: > > With the .htaccess configured as above, mptest.py works correctly when I > point the browser to http://localhost/mod_python/mptest and > prints the Hello World! > > I comment line 2 of the .htaccess and uncomment line 3, and the browser > reports a 404 Error stating that The requested URL /mod_python/mptest.py was > not found on this server(note that the URL remained the same in the > browser). I also find it interesting to note that in either configuration, > the PythonHandler mod_python.psp functions correctly, and the > apache2/access.log and error.log report nothing more than a 404 error. > > Now I thought about just removing the mod_python.publisher altogether and > using multiple Python handlers for the .py files, but the implementation > failed for some reason. My plan was to make an entry for each .py file in > the same way you would make an entry for every servlet in a web.xml file. It > seems as though no matter where or in what order I put the PythonHandler > lines in, if I make a call to one of them, all of them are executed. > > This I assume, means that I really have to have a mod_python.publisher > working. Any help would be greatly appreciate. > > Regards, > Ken Bradshaw > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051006/d30a7f85/attachment.html
|