Mailing List Archive

database connection
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:

''''''''

Site Error

An error was encountered while publishing this resource.

Resource not found
Sorry, the requested resource does not exist.

Check the URL and try again.

Resource: http://jura:9673/RefDB/Psycopg_database_connection/NONE

Troubleshooting Suggestions

* The URL may be incorrect.
* The parameters passed to this resource may be incorrect.
* A resource that this resource relies on may be encountering an error.

For more detailed information about the error, please refer to the error
log.

If the error persists please contact the site maintainer. Thank you for
your patience.
''''''


what should I do? I think it is strange that it shows the first 20
results withour problems but does not work when I try to display the
next 20 results. Any suggestions?

thx,

Martin
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: database connection [ In reply to ]
On 2006-01-10 at 12:50:41 [+0100], Martin Krallinger <martink@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
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: database connection [ In reply to ]
On 2006-01-10 at 13:06:30 [+0100], Martin Krallinger <martink@cnb.uam.es>
wrote:
> Thanks Charlie,
>
> so, how could I solve this problem in my case?

Please keep replies like this on the mailing list.

Well, you can fix the DTML of the page in question so that the parameters
are carried or simply write a report page with your own batching mechanism
to pass the parameters through. I think this has been fixed in versions of
Zope > 2.7

Charlie
--
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2005-10-17: Released mxODBC.Zope.DA 1.0.9 http://zope.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
RE: database connection [ In reply to ]
>On 2006-01-10 at 12:50:41 [+0100], Martin Krallinger
<martink@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
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db