[Zope] Little ZSQL snippet

Tony McDonald tony.mcdonald@ncl.ac.uk
Thu, 8 Apr 1999 15:15:40 +0100


Just so's you don't think I never get *anything* to work... :)

I was showing a colleague how to do some Zope SQL lookups. Tres Neat. 
Then it came to passing a parameter to the ZSQL method.

get_single_event is the following ZSL method
argument::
event_num
SQL::
select event_num, event_title, DATE_FORMAT(event_date, "%H:%i %W, %M 
%D") as event_date,
event_venue,
event_details,
event_speaker,
event_contact,
event_email,
upload_ip,
DATE_FORMAT(upload_date, "%W, %M %D %H:%i") as upload_date
from event where event_num =
<!--#sqlvar event_num type=string-->

The code that calls it is;
<!--#if event_num -->			# ie make sure that event_num exists
<!--#in get_single_event-->		# you *don't* need to make 
event_num a parameter!
<TABLE BORDER="0" WIDTH="100%">
dump your data...

and the whole things works beautifully.

I had tried
<!--#in get_single_event(event_num) --> , <!--#in 
"get_single_event(event_num)" -->, <!--#in 
"get_single_event(REQUEST['event_num'])" -->

and all sorts of combinations with no joy.

Learning more Zopista tricks day by day...
hope this helps,
tone.
------
Dr Tony McDonald,  FMCC, Networked Learning Environments Project
The Medical School, Newcastle University Tel: +44 191 222 5888
Fingerprint: 3450 876D FA41 B926 D3DD  F8C3 F2D0 C3B9 8B38 18A2