Graham Dumpleton
grahamd at dscpl.com.au
Sun Jun 5 18:14:37 EDT 2005
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. Are you using mpservlets as the actual handler, ie.: AddHandler python-program .mps PythonHandler mod_python.servlet or triggering mpservlets from a handler of your own creation somehow? What is the URL you are using for the request? Are you using "test.mps", "test.html" or just "test" with no extension? Given you say it works for one browser and not another, then can only speculate that based on request headers sent by browser Apache is making a different decision as to what to serve up. This though could only be the case though if "MultiViews" was enabled and you were using URL of just "test" with no extension and Apache was as a result was having to make a choice between serving up "test.html" as a static file or running the mod_python handler for "test.mps". If these assumptions are somehow right, make sure you disable MultiViews by specifying in your Apache configuration: Options -MultiViews for that part of the directory heirachy, and make sure you always use "test.mps" explicitly. You might lesson the risk of a problem by still calling your PSP file "test.psp" and not "test.html" and then forbidding direct access to all .psp files using: <Files *.psp> deny from all </Files> in your Apache configuration. 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. Overall, only thing I see where you perhaps gain something from mpservlets with the way you are using it, is the fact that it can dispatch to different handlers contained in separate files in the same directory. If this is all you are really after, you may find it less complicated to use Vampire. If you are using mpservlets because the handler is then an object, that is easy enough to accomplish with basic handlers as the handler can be any callable object anyway and it would be straight forward to write your own servlet like handler better suited to how you want to do things. Graham
|