[ZPT] FORMs and processing

Tony McDonald tony.mcdonald@ncl.ac.uk
Tue, 26 Jun 2001 21:38:39 +0100


On 26/6/01 4:45 pm, "Evan Simpson" <evan@digicool.com> wrote:

> From: "Tony McDonald" <tony.mcdonald@ncl.ac.uk>
>> <dtml-in do_an_sql_query_that_only_returns_one_row>
>> <dtml-if submit>
>>     do stuff with the data.
>> </dtml-if>
>> 
>> <form method="post">
>> <input type="text" name="surname" value="<dtml-var surname missing>">
> 
> A literal translation of this would look like:
> 
> <div tal:repeat="row do_an_sql_query_that_only_returns_one_row">
> <div tal:condition="exists:request/submit">
>   do stuff with the data.
> </div>
> <form method="post">
> <input type="text" name="surname" tal:attributes="value request/surname
> | nothing">
> 

That's really neat, I can follow how that's working...

> ...but the sql query and "do stuff" look like prime candidates for a
> Script.
> 

Do you mean that the sql_query should set local variables?, ie
<span tal:define="surname row/surname" />

(does this mean that the variable is defined in the context of the whole PT,
or just the span).

I agree that 'do stuff' should be a Script, in my case it would be doing SQL
updates and calling methods to send emails etc. Is it sensible to do
something like;

<span tal:replace="here/do_stuff" />

Where do_stuff is a DTML method like

<dtml-call "update_table(REQUEST)">
<dtml-call "send_email(REQUEST)">

Or is this not the Zen of PT? :)

Many thanks Evan - sorry, it seems more and more questions. I saw the
screendump of the new Zope site at
http://dev.zope.org/Wikis/DevSite/Projects/ZopeOrgCollaborationEnhancement/M
ockUp and the two words 'PT Source' look very very interesting! ;)

Cheers
Tone.
-- 
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope