Hi, Going out of my brain here. I want to create a method in Zope that goes off and replicates a current Access query, and am falling over at the same hurdle every time. The WHERE line of the current Access query reads: WHERE ((([Daily Orders].Date) Between [Enter the beginning date] And [Enter the end date])) If I replace [Enter the beginning date] and [Enter the end date] with #mm/dd/yyyy# and #mm/dd/yyyy# then I get the expected output when testing my database connection in Zope. So now I have the form that collects those dates in the correct order from the user; <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 the part I can't get my head round. I presume these values now exist in the REQUEST? So do I put instructions into the ZSQL method in place of the [Enter the start date] and [Enter the end date] fields to fetch the info from REQUEST? If so, then I must be reading this manual wrong because I can't get it to happen ;-) If anyone can guide me in what I should go learn to tie the form to the query I'd be eternally grateful, and promise not to offer to do favours for people again until I study a bit harder. andy
ZSQL Methods have a field "Arguments" where you can place the variables from the request you would like to use in the method. Seperate them with spaces. So in this case Arguments should contain "startdate enddate" (no quotes). Then just use <dtml-var startdate fmt="#%s#"> (unfortunately, you can't use dtml-sqlvar because it would quote the result) andy wrote:
Hi,
Going out of my brain here. I want to create a method in Zope that goes off and replicates a current Access query, and am falling over at the same hurdle every time.
The WHERE line of the current Access query reads:
WHERE ((([Daily Orders].Date) Between [Enter the beginning date] And [Enter the end date]))
If I replace [Enter the beginning date] and [Enter the end date] with #mm/dd/yyyy# and #mm/dd/yyyy# then I get the expected output when testing my database connection in Zope. So now I have the form that collects those dates in the correct order from the user;
<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 the part I can't get my head round. I presume these values now exist in the REQUEST? So do I put instructions into the ZSQL method in place of the [Enter the start date] and [Enter the end date] fields to fetch the info from REQUEST? If so, then I must be reading this manual wrong because I can't get it to happen ;-) If anyone can guide me in what I should go learn to tie the form to the query I'd be eternally grateful, and promise not to offer to do favours for people again until I study a bit harder.
andy
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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
participants (3)
-
andy -
Chris Beaven -
Fernando Martins