[mod_python] PSP Templating printing in plain text

Matt Shaw matt.shaw at elanit.co.uk
Tue Nov 22 06:08:52 EST 2005


I have been playing with Python for making a web project, mainly to learn
the Python language and realised that the most painful part of it all was
not the Python at all but the CGI, so found MOD_PYTHON and am going to use
this as seems perfect.  However when following the example below, it outputs
to the browser as plain text with all the tags shown and not as tho its
HTML, I'm using the Ubuntu 5.10.  Oddly enough it does actually swap out the
variable, so it is kinda working :-) Any help would be appreciated.
 
Here is a snippet of the relevant Apache configuration for using the
Publisher:

<Directory /your/document/root>

SetHandler mod_python

PythonHandler mod_python.publisher

PythonDebug On

</Directory>

Since we're using PSP as a templating mechanism, we need a template. Let's
assume it is in a file named /your/document/root/hello.tmpl:

<html>

   <h1><%= greet %></h2>

</html>

Here is the Python script. Let's assume it is in a file called
/your/document/root/pubpsp.py.

from mod_python import psp



def hello(req, name=''):

   s = 'Hello, there!'

   if name:

       s = 'Hello, %s!' % name.capitalize()



   tmpl = psp.PSP(req, filename='hello.tmpl')

   tmpl.run(vars = { 'greet': s })

   return


- ---------------------------------------------------------------------
Elan is the world's leading IT&T recruitment company. For more information go to www.ElanIT.com.

- ---------------------------------------------------------------------
The contents of this email and any attachment are confidential to the addressee and are intended solely for the addressee's use.  If you are not the addressee, you have received this email in error.  If so, you must not disclose, copy or take any action in reliance on this email and any attachment.  If you received this in error, please contact the sender and delete the material from your computer.  

Although this email and any attachment have been checked for viruses, no liability is accepted by Elan in this regard.  The recipient should carry out virus and other checks as it deems necessary to ensure that this email and any attachments will not adversely affect its systems or data.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051122/5b5516fe/attachment.html


More information about the Mod_python mailing list