David Fraser
davidf at sjsoft.com
Tue Oct 11 03:12:32 EDT 2005
Right, I wasn't concentrating. I don't think that would be a good idea at all as it would just confuse the issue :-) But if we decide to continue the builtin testhandler idea that could be done there... Nicolas Lehuen wrote: > Hi, > > That's a good idea, we could just add an index() method to the mptest > module. There is no real mptest module, though. It's just some text in > a tutorial. > > Regards, > Nicolas > > 2005/10/11, David Fraser <davidf at sjsoft.com <mailto:davidf at sjsoft.com>>: > > Hi Nicolas > > I wonder if it wouldb e helpful to add a publisher-style handler > to the > mptest module. This could return a page that says "this is being > served > by the publisher" with some explanation - that way people will at > least > be told what is happening... > > David > > Nicolas Lehuen wrote: > > > 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 > <http://www.modpython.org/live/current/doc-html/tut-pub.html> > > <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 > <mailto:bradshak at us.ibm.com> > > <mailto:bradshak at us.ibm.com <mailto: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 >
|