Retrieving a set number of entries
Hi, I'm building a database interface in Zope. We are using Zope 2.6, Python 2.1.3, and the database is in PostGreSQL 7.3.3. The problem I am having is trying to search the database and return a set number of entries. Like how Yahoo! returns 25 possibilities in it's search per page. Or how Google returns 10. I'd like to know how to code it so that a database search returns a set number of entries found, and can make pages with multiple entries if there's more than the set number of entries on a page. Anyone have any ideas? -- Lalo Castro Programmer/Analyst McHenry Library (831) 459-5208
It's easy to create some code that does this in Zope. Create a ZSQL method that does a select on your database. Then drag down the products menu and add a "Z Search Interface." It will prompt you for the name of a search document and a report document and will automagically create a results page that does just what you're looking to do. We use this as a quick and dirty way to write a search interface and then go hack up the code to make it look the way we want. The "size" attribute of the dtml-in tag of the results page is where you tweak how many you want on a page. - Chris On Thursday, October 16, 2003, at 04:37 PM, Lalo Castro wrote:
Hi, I'm building a database interface in Zope. We are using Zope 2.6, Python 2.1.3, and the database is in PostGreSQL 7.3.3. The problem I am having is trying to search the database and return a set number of entries. Like how Yahoo! returns 25 possibilities in it's search per page. Or how Google returns 10. I'd like to know how to code it so that a database search returns a set number of entries found, and can make pages with multiple entries if there's more than the set number of entries on a page. Anyone have any ideas? -- Lalo Castro Programmer/Analyst McHenry Library (831) 459-5208
_______________________________________________ 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 )
I'm building a database interface in Zope. We are using Zope 2.6, Python 2.1.3, and the database is in PostGreSQL 7.3.3. The problem I am having is trying to search the database and return a set number of entries. Like how Yahoo! returns 25 possibilities in it's search per page. Or how Google returns 10. I'd like to know how to code it so that a database search returns a set number of entries found, and can make pages with multiple entries if there's more than the set number of entries on a page. Anyone have any ideas?
There's also a ZPT library for doing this. Plone throws this around all the time if you want to look at an exapmle. folder_contents, for example. --jcc
Hi Lalo, Lalo Castro wrote:
Hi, I'm building a database interface in Zope. We are using Zope 2.6, Python 2.1.3, and the database is in PostGreSQL 7.3.3. The problem I am having is trying to search the database and return a set number of entries. Like how Yahoo! returns 25 possibilities in it's search per page. Or how Google returns 10. I'd like to know how to code it so that a database search returns a set number of entries found, and can make pages with multiple entries if there's more than the set number of entries on a page. Anyone have any ideas?
Dont be mislead by the other answers :) I hope you dont have to use DTML, so you can concentrate on the recommended way. The key here is to use the ZTUtils.Batch class as utility for batching (API documentation is in the ZopeBook, there are several examples you will find with Google. Try not to mix it into ZPT, like some examples show but use a small python script and return the values from there. Good luck Tino Wildenhain
participants (4)
-
Chris Muldrow -
J Cameron Cooper -
Lalo Castro -
Tino Wildenhain