[Zope] newbie: stupid Access zsql problem
Fernando Martins
fmartins@hetnet.nl
Thu, 20 Feb 2003 23:47:07 +0100
andy wrote:
[...]
> The WHERE line of the current Access query reads:
>
> WHERE ((([Daily Orders].Date) Between [Enter the beginning date] And
> [Enter the end date]))
>
[...]
>
> <form method=POST action="query">
> Enter the start date: <input type=text name=startdate size=10
> maxlength=10>
> <p>
> Enter the end date: <input type=text name=enddate size=10 maxlength=10>
> <p>
> <i>Ensure dates are entered in mm/dd/yyyy format</i>
> <p>
> <input type=submit>
> </form>
>
> ... and I want to pass those values into the ZSQL Method, and this is
[...]
quick and simple answer - not tested, see ISSUES:
a) in zsql replace [Enter the beginning date] and [Enter the end date] by
<dtml-var STARTDATE> and <dtm-var ENDDATE>
b) in zsql Parameters write simply STARTDATE ENDDATE
c) test the zsql!
d) call the zsql method QUERY from a Page Template like this:
tal:define="recordset
python:container.QUERY(STARTDATE=request.form.startdate,
ENDDATE=request.form.enddate)"
to get the set of records and use it afterwards, or
tal:repeat="record python:..."
to imediately loop over the records (foreach) and repeat html stuff like
<TR>.
ISSUES:
1) I used capital letters but it's not necessary. I used them just to
visually differentiate from the form parameters.
2) You might have to do #<dtml-var ...>#
3) Look for <dtml-sqlvar> in the documentation (e.g. zope book). It includes
a parameter 'type' that's supposed to take care of type representation
issues (point 2) according to the database.
4) Obviously you can call the zsql method from a Python script (like in d)
and from DTML but for this one I don't know.
HTH,
Fernando