On Tue, 2002-03-26 at 08:29, Jeff Peterson wrote: <snip>
it makes more sense to me to call it in your template:
Page Template ============= (might have to massage the param/value part if it's needed; get it from request or some other way)
<table tal:define="data python:here.your_sql([param=value])"> <tr tal:repeat="items data"> <td><LABEL for="firstname">First name: </LABEL></td> <td><INPUT type="text" name="first_name" value="" tal:attributes="value items/colname" tal:on-error="string:"> </td> </tr> </table>
The problem with this, though, is that I don't want to call the database in my template. I want the template to be re-used by 3 different DTML methods: add, edit & search. When adding and searching, I'm not executing a database query until the user hits the submit button. But in the case of 'edit', I'm passing the personid that I want to edit, so the edit dtml method executes the query and then invokes the template. Here's what my edit method looks like (it's invoked with the parameters "?personid=x"): <dtml-var standard_html_header> <h2><dtml-var title_or_id> <dtml-var document_title></h2> <dtml-in expr="get_customer(pid=personid)"> <form action="&dtml-URL0;" method="post"> <input type="hidden" name="personid" value=<dtml-var personid> > <dtml-var genericform_html> </form> </dtml-in> <dtml-var standard_html_footer> I know that the form submission is wrong - that I'll need an intermediate script to rewrite the data back into the tables. But right now I'm just trying to populate the form with the values from the query. It seems to me that this is an appropriate thing for templates. Is there a better way to do this (re-usable forms)? -- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F