[mod_python] PSP Templating

John Ruff jcruff at gmail.com
Thu Mar 1 10:18:45 EST 2007


Thanks Olaf.  Is this a new requirement?  It's not mentioned in the  
PSP 3.3 docs example for templating.  Also, I didn't see this issue  
when previously using 3.2.10.

Thanks.
___________________
John Ruff
jcruff at gmail.com
GPG Key: 0x1F691195
FGPR: 6B50 37C9 10F9 6C4A D381  54B8 319D 7DD9 1F69 1195

"No one can see past a choice they don't understand." --The Oracle


On Mar 1, 2007, at 10:13 AM, Olaf Stein wrote:

> Add
> req.content_type = 'text/html'
> Before your tmpl.run(vars = {'greet':s})
>
> Olaf
>
> On 3/1/07 9:40 AM, "John Ruff" <jcruff at gmail.com> wrote:
>
>> I'm trying to understand what I'm doing wrong.  I'm using mod_python
>> 3.3.1 with apache 2.2.4.  The situation is that while trying to use
>> PSP as a templating engine, none of the examples work.  Yet normal
>> 'SetHandler mod_python' with inline html works no problem.
>>
>> I have the following:
>>
>> <Directory "/home/<user-dir>/Sites/python">
>>      SetHandler mod_python
>>      PythonHandler mod_python.publisher
>>      PythonOption mod_python.psp.cache_database_filename "/tmp/
>> pspcache.dbm"
>>      PythonDebug On
>> </Directory>
>>
>> ====hello.py====
>> from mod_python import apache, psp
>>
>> def hello(req):
>>      s = 'Hello, there!'
>>      tmpl = psp.PSP(req, filename = 'hello.tmpl')
>>      tmpl.run(vars = {'greet':s})
>>      return apache.OK
>>
>> ====hello.tmpl====
>> <html>
>> <body>
>>      <h1><%=greet%></h1>
>> </body>
>> </html>
>>
>>
>> Still, I'm presented with a webpage that's raw html of what would
>> have been generated.  When using firefox's Web Developer toolbar to
>> see the generated source I can see that my html has been surrounded
>> by an '<html><head></head><body><pre>...</pre></body></html>' block.
>> So it looks like this:
>>
>> [snip]
>>
>> <html><head></head><body><pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD
>> XHTML 1.0 Strict//EN"
>>      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
>>
>> &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
>> lang="en"&gt;
>> &lt;head&gt;
>>      &lt;meta http-equiv="Content-Type" content="text/html;
>> charset=utf-8"/&gt;
>>
>>      &lt;title&gt;hello&lt;/title&gt;
>>
>>
>> &lt;/head&gt;
>>
>> &lt;body&gt;
>>      &lt;h1&gt;Hello, there!&lt;/h1&gt;
>> &lt;/body&gt;
>> &lt;/html&gt;
>> </pre></body></html>
>>
>> [/snip]
>>
>> Any ideas why this is happening?
>> ___________________
>> John Ruff
>> jcruff at gmail.com
>> GPG Key: 0x1F691195
>> FGPR: 6B50 37C9 10F9 6C4A D381  54B8 319D 7DD9 1F69 1195
>>
>> "No one can see past a choice they don't understand." --The Oracle
>>
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>
>
>
> -------------------------
> Olaf Stein
> DBA
> Center for Quantitative and Computational Biology
> Columbus Children's Research Institute
> 700 Children's Drive
> phone: 1-614-355-5685
> cell: 1-614-843-0432
> email: steino at ccri.net
>



More information about the Mod_python mailing list