[Zope] ZSQL Method Question

Tony McDonald tony.mcdonald@ncl.ac.uk
Thu, 7 Oct 1999 13:12:50 +0100


At 7:21 pm -0500 7/10/99, Ping Lau wrote:
>Hello,
>
>Can anyone explain how ZSQL Method makes info available to DTML?  For
>example, getCustomer is a ZSQL Method and I used it in a DTML method:
>
><dtml-in "getCustomer(id=123)">
>  <dtml-var id>
>  <br>
>   <dtml-var name>
></dtml-in>
>
>I would like to know how id & name, which are fields of customer table,
>magically become available.  Thanks.
>
>Regards,
>Ping

Essentially it depends on your database adaptor, but Zope creates a 
'namespace' within the <dtml-in  ... > ... </dtml-in> tags which 
makes those variables returned by the database adaptor available.

Note that your choice of 'id' and 'name' might cause conflicts with 
the Zope 'id' and 'name' part of the dtml tag.

If you have a ZSQL method called 'lookup', parameter personid:int 
that has this format
select name as firstname, surname, id as personid, title from person 
where id = <dtml-sqlvar personid type=int>

then you can do
<dtml-in "lookup(personid=44)">
<dtml-var title null="">&nbsp;<dtml-var firstname>&nbsp;<dtml-var 
surname>, <dtml-var personid><br>
</dtml-in>

which won't give you grief with Zope variable names.
hth and glad to see you've stopped using HTML mail :)
tone.
------
Dr Tony McDonald,  FMCC, Networked Learning Environments Project 
http://nle.ncl.ac.uk/
The Medical School, Newcastle University Tel: +44 191 222 5888
Fingerprint: 3450 876D FA41 B926 D3DD  F8C3 F2D0 C3B9 8B38 18A2