[ZPT] zpt python and tables

Robert Hibberdine bob.hibberdine at ntlworld.com
Tue Aug 3 07:55:27 EDT 2004


Hello all,

I have a web page where I display data in a table. I use ZPT and the data is 
generated by a Python script accessing a database. The table is generated by 
using the tal:repeat statement.

So far so godd. Its all nice and simple and it works fine..

But, now I want to add some bells & whistles:

I want each cell in the table to be a link to another Python generated table. 
The Python script needs to take its 2 parameters from the first row and column 
of the original table.

I am a newbie in Zope. I couldn't see how to do this with ZPT so I thought that 
   I'd use ZPT to keep my basic page looking as I want and then generate the 
actual table using Python. I did this as follows:

<table>
<tr tal:repeat="myrow python:here.myscript()" tal:content="myrow"">row</tr>
</table>

This didn't work because although "myscript()" produces a list of strings (1 
string per row) each containing something like:

<td class="cd_1">data1</td> ........ <td class="cd_1">data9</td>

It gets rendered as:

&lt;td class="cd_1"&gt;data1&lt;/td&gt; .......... etc

The html that I am generating get interpreted literally. After much cursing I of 
course realised this made sense. _Content_ substitution .....

But I would still like to do what I want this way. So can I generate my table
by somehow 'escaping' the html so that it goes to the page as html??

TIA

Bob



More information about the ZPT mailing list