[Zope-DB] database connection

Rivera Merla Jose JRIVERA at oxxo.femsa.com.mx
Tue Jan 10 18:33:32 EST 2006


>On 2006-01-10 at 12:50:41 [+0100], Martin Krallinger
<martink at cnb.uam.es> 
>wrote:
>> Hi all,
>> 
>> 
>> I am using zope to connect to my postgres database using psycopg.
>> Everything works fine, I can connect to the db and do queries, the
first
>> 20 results are displayed correctly, but when I want to display the
>> '(Next 20 results)' I get the following error:
>
>This is a standard error in ZSQL's test pages and is due to the fact
that >the 
>query parameters are not included in the link for the next 20 results.>
>
>Charlie
>

Hi

The problem can be found where the page template defines the link to the
next 20 pages, look:

  <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>


Do you see the code '?start:int', you should add there the parameters
needed for your ZSQL or take the easy path of change the batch size to a
big number like 65000.

You can do these using this lines:
                    batch python:modules['ZTUtils'].Batch(results, 
                                                          size=65000, 
                                                          start=start);
instead of:

                    batch python:modules['ZTUtils'].Batch(results, 
                                                          size=20, 
                                                          start=start);

I hope this can be of any help...

Bye
Jose Rivera Merla


More information about the Zope-DB mailing list