[ZPT] Best way of getting the first results from ZSQL queries

Tony McDonald tony.mcdonald@ncl.ac.uk
Fri, 06 Sep 2002 11:46:11 +0100


On 6/9/02 4:59 am, "Casey Duncan" <casey@zope.com> wrote:

> You'd be much better off coding this in a Python script that either returned
> the record (or None) or set the global variable into the request.
> 
> something like:
> 
> form = context.REQUEST.form
> if form.has_key('autoid'):
>   data = container.get_teaching(autoid=form['autoid'])
>   if data:
>       return data[0]
> return None # You can omit this line, but it makes it clear
> 
> Let's say this script is called "get_form_data" then in your template put
> something like:
> 
> <body tal:define="form_data container/get_form_data">
> ...Do Stuff..
> <div tal:condition="form_data">
>   ..do stuff with form_data..
> </div>
> </body>
> 
> hth,
> 
> -Casey

Thought a python script might be the best way of doing it :) - it's also
very clean as well, so I think I can show this to the team without heads
popping.

Many thanks for that Casey, I guess I still have my DTML head on (ie do it
all in the script!)

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