urgent! wrong query results on next/previous urls in ZSQL/Zsearch
Hi folks, I'm 3 days before rollout of my first Zope project and now discover my ZSQL / Z Search Interface yields wrong query results! Only the first 20 query results are o.k., navigating around with next/previous "forgets" the user search form inputs constructing the SQL WHERE clause. Details: 1. I Use Zope 2.6.0 with python 2.1.3 and mysql 3.23-48. 2. First I created a zsql method: select * from usertable <dtml-sqlgroup where> <dtml-sqltest Userid op=like type=nb optional> <dtml-and> <dtml-sqltest Nachname op=like type=nb optional> <dtml-and> <dtml-sqltest Vorname op=like type=nb optional> </dtml-sqlgroup> 3. Then I added an Z Search Interface, which produced the following page templates: ########################################################## ... <form action="fp1b" method="get"> <h2 tal:content="template/title_or_id">Title</h2> Enter query parameters:<br><table> <tr><th>Userid</th> <td><input name="Userid" width=30 value=""></td></tr> <tr><th>Nachname</th> <td><input name="Nachname" width=30 value=""></td></tr> <tr><th>Vorname</th> <td><input name="Vorname" width=30 value=""></td></tr> <tr><td colspan=2 align=center> <input type="SUBMIT" name="SUBMIT" value="Submit Query"> ... ########################################################## ... <body tal:define="results here/fp1user_query_sqlmethode_argu; start request/start|python:0; batch python:modules['ZTUtils'].Batch(results, size=20, start=start); previous python:batch.previous; next python:batch.next"> <p> <a tal:condition="previous" tal:attributes="href string:${request/URL0}?start:int=${previous/first}" href="previous_url">previous <span tal:replace="previous/length">20</span> results</a> <a tal:condition="next" tal:attributes="href string:${request/URL0}?start:int=${next/first}" href="next_url">next <span tal:replace="next/length">20</span> results</a> </p> <table border> <tr> <th>Userid</th> <th>Vorname</th> <th>Nachname</th> </tr> <div tal:repeat="result batch" > <tr> <td><span tal:replace="result/Userid">Userid goes here</span></td> <td><span tal:replace="result/Vorname">Vorname goes here</span></td> <td><span tal:replace="result/Nachname">Nachname goes here</span></td> </tr> ... <a tal:condition="previous" tal:attributes="href string:${request/URL0}?start:int=${previous/first}" href="previous_url">previous <span tal:replace="previous/length">20</span> results</a> <a tal:condition="next" tal:attributes="href string:${request/URL0}?start:int=${next/first}" href="next_url">next <span tal:replace="next/length">20</span> results</a> </p> ... ######################################################### 4. A direct test of the ZSQL in the test tab works perfectly, e.g. searching all userids starting with C produces 20 results, you click "next 20 results" and get the next 20 hits and so on. 5. When using the Zope-generated Z Search page templates, you can also choose your query parameter C% and get the first 20 hits correctly. BUT: IF YOU NOW PRESS NEXT 20 RESULTS, YOU GET THE 20 VERY FIRST ROWS OF THE WHOLE TABLE! 6. A MySql Trace shows that the first query is SELECT * FROM usertable WHERE userid LIKE C%; this is fine clicking the "next url" yields another query with SELECT * FROM usertable; 7. Obviously something must be wrong with the "next url": <a tal:condition="next" tal:attributes="href string:${request/URL0}?start:int=${next/first}" It does not know about the SQL query parameters from the first call!? 8. Any ideas how to navigate correctly through this ZSQL result ? When I compare to the ZSQL test tab, there a much longer url is composed when going to the "next 20 results" link. Regards Peter __________________________________________________________________ Tiscali Mobile NEU! Die neuesten Klingeltöne, Logos, Mailboxsprüche, Bildmitteilungen und Screensaver für alle Handytypen. Einfach und günstig! Klicken Sie hier: http://www.tiscali.de/mobile/
k0878290@tiscali.de wrote at 2003-2-27 11:01 +0100:
I'm 3 days before rollout of my first Zope project and now discover my ZSQL / Z Search Interface yields wrong query results! Only the first 20 query results are o.k., navigating around with next/previous "forgets" the user search form inputs constructing the SQL WHERE clause. ....
This is a bug in the "Z Search Interface". It creates a wrong report ZPT.
.... tal:attributes="href string:${request/URL0}?start:int=${previous/first}" As you see, the query parameters are not passed.
You can use funtions "make_query" (or similarly spelled) from the "ZTUtils" package to pass the query parameters. File a collector report: <http://collector.zope.org/Zope>, such that this bug can be fixed. Dieter
Hi, ahaaaa! I now posted the bug to collector.zope.org, but any result will be too late for my go-live. Is there some example available anywhere, which is the equivalent to the automatically generated Z Search forms ? In the zope manual and on all zope sites there is no code available using make_query. Peter
This is a bug in the "Z Search Interface". It creates a wrong report ZPT.
.... tal:attributes="href string:${request/URL0}?start:int=${previous/first}" As you see, the query parameters are not passed.
You can use funtions "make_query" (or similarly spelled) from the "ZTUtils" package to pass the query parameters.
File a collector report: <http://collector.zope.org/Zope>, such that this bug can be fixed.
Dieter
__________________________________________________________________ Tiscali Mobile NEU! Die neuesten Klingeltöne, Logos, Mailboxsprüche, Bildmitteilungen und Screensaver für alle Handytypen. Einfach und günstig! Klicken Sie hier: http://www.tiscali.de/mobile/
Peter Marx wrote at 2003-2-28 12:03 +0100:
ahaaaa! I now posted the bug to collector.zope.org, but any result will be too late for my go-live.
Is there some example available anywhere, which is the equivalent to the automatically generated Z Search forms ? In the zope manual and on all zope sites there is no code available using make_query.
It looks like this: <SOMETAG tal:define="mq python:modules['ZTUtils'].make_query; p batch/previous; " <a tal:attributes="href python: '?' + mq(request.form,b_start=p.first)"> Previous</a> </SOMETAG> "batch" is a batch defined elsewhere, "b_start" is its start parameter. You will probably find these (maybe a bit differently named) in your generated template. Dieter
participants (3)
-
Dieter Maurer -
k0878290@tiscali.de -
Peter Marx