[spam] [ZPT] Help with ZPT, python, and zsql

Philip Kilner phil at xfr.co.uk
Wed Mar 2 02:58:09 EST 2005


Hi Tom,

Tom Twyman wrote:
> I am trying to put together a Zope site with Zsql and ZPT.  Currently, I 
> have  a zpt that displays results from a zsql method (sqlvw_classes):
> 
> <tr tal:repeat="item here/sqlvw_classes" >
> 
> <td tal:content="item/classid">
> Class ID
> </td>
> <td tal:content="item/class_title">
> Class title
> </td>
> <td tal:content="item/class_length_hrs">
>  Class Hours
> </td>
> <td tal:content="item/class_price">
>  Class Price
> </td>
> <td tal:content="item/class_desc">
>  Class Desc
> </td>
> <td>
> <a href="fmclassedit classid=3" tal:define="classid item/classid">Edit 
> this class</a>
> </td>
> </tr>
> 
> 
> The page correctly displays information from a Postgresql table.  I 
> would like to add an anchor tag <a> that would allow the user to click a 
> link, and be taken to a form that allows them to edit the record they 
> clicked.  I can put together a form easily enough, and attach it to a 
> zsql UPDATE method, but I am having trouble figuring out:
> 
> - how to create the link using the class title
 > - passing the classid to the zsql method and zpt form I will use to
 > perform the update
 >

You will need to use the tal:attributes tag to dynamically generate the 
link: -

<a tal:attributes="href 
string:${request/URL1}/form_page?classid=${item/classid}"
               href="form_page"><span 
tal:replace="item/class_title">class_title goes here</span></a>

- tal:attributes replaces href="form_page" with a URL formed by bolting 
together the current URL's "folder", the target document name 
(form_page) and an appropriate query string (e.g. the parameter to 
select the class).

HTH

-- 

Regards,

PhilK

Email: phil at xfr.co.uk / Voicemail & Facsimile: 07092 070518

"When the going gets weird, the weird turn pro."
-- Hunter S. Thompson 1937-2005. RIP.


More information about the ZPT mailing list