Colin Doherty
coldoherty68 at yahoo.co.uk
Mon Jun 6 15:13:53 EDT 2005
Hi, I'm referring to the servlet as test without any extension. I've tried adding Options -Multiview and that hasn't made any difference. One thing I didn't mention is that I'm using mod_proxy to forward the requests to an apache server running as a dedicated mod_python server, so could this be having some sort of interaction ? I'm using servlets for the very reasons you specify Daniel, I think it is a very elegant and efficient way of developing web apps using mod_python. Cheers Colin --- "Daniel J. Popowich" <dpopowich at blue-fox.com> wrote: > > To clarify a few points made by Graham... > > > On 06/06/2005, at 2:04 AM, Colin Doherty wrote: > > > I'm using mod_python servlets and psp and > although the > > > code works correctly for IE, the source code of > the > > > template is displayed with Mozilla and Firefox > when > > > called from the servlet. > > > > > > I'm setting the content type within the servlet: > > > > > > class test(Servlet): > > > content_type = 'text/html' > > > > > > and calling the template thus: > > > > > > def respond(self): > > > Servlet.respond(self) > > > template = PSP(self.req, > filename='test.html') > > > template.run({'servlet':self}) > > > return True > > > > > > Any suggestions appreciated. > > > > > What is the URL you are using for the request? Are > you using "test.mps", > > "test.html" or just "test" with no extension? > > > > Options -MultiViews > > > > mod_python servlets (mps) enforces "clean" urls, so > the only way to > access a servlet in "test.mps" is with "test", so > MultiViews, in my > experience, has to be turned off as Graham says. > > > for that part of the directory heirachy, and make > sure you always use > > "test.mps" explicitly. > > This is incorrect: using "test.mps" explicitly will > fail and return a > 404 error. > > mps does the following for req.filename: > > 1. If it's a directory, "DIR," do a brute-force > internal redirect > to "DIR/index". > > 2. If the basename begins with "." or "_" > return 403. This > allows you to co-locate data files or other > python source > without worry of being downloaded by prying > eyes. (Future > versions may check every component of the > path to see if it > begins with "." or "_" so whole directory > hierarchies can be > forbidden. > > 3. If req.filename has an extension: > a) if the extension is ".mps" return 404 > (this is where > "clean" urls are enforced). > b) otherwise return apache.DECLINED if the file > exists, else 404. > > 4. If req.filename has no extension: > > a) if req.filename + ".mps" exists use > it. > b) otherwise return apache.DECLINED if > the file > exists, else 404. > > Note how mps returns apache.DECLINED for non ".mps" > files...this > allows you to co-locate ANY mimetype: html, php, > psp, jpg, gif, > etc. within a directory "handled" by mps. In fact, > you can set your > DocumentRoot to be handled by mps and all your > content should be > handled as expected (except for MultiViews and the > extra performance > hit of mps). > > In otherwords, with MultiViews off you can co-locate > test.mps, > test.html, test.php, test.psp all in the same > directory without > failure. > > > BTW, why specifically are you using mpservlets as > when using PSP you may > > find they don't mesh very well? For example, one > of the points of using > > mpservlets is that by supplying its own > write/writeln methods in the > > servlet it does its own buffering of output. > Because PSP is going to > > write direct to the request object using > req.write(), the buffering in > > mpservlets is bypassed. Another reason people use > mpservlets is that it > > has some session support, but then so does PSP. > > <soapbox> > While output buffering and session handling are > bonuses, the main > reason I wrote mps was to have an OO view of the > web. Writing an > abstract base class that manages the overall layout > of a site and > then writing subclasses for specific pages is, imho, > very powerful. > Also, being able to re-use base class features in > every servlet > (particularly form/query variable processing) saves > hours of > programming. > </soapbox> > > Cheers, > > Daniel Popowich > ----------------------------------------------- > http://home.comcast.net/~d.popowich/mpservlets/ > ___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
|