On Fri, 2003-12-05 at 12:12, Lyz@PrincessLeia.com wrote:
I'm fairly new to Zope,
Welcome.
I have a database that's full of information I'd like to return. I created a Z SQL method to select * from table, and using <dtml-in ...> I can return all the results I need, but there are too many.
I'd like to only show 5 at a time, then have a links at the bottom so you can jump to database results 1-5, 6-10, 11-15, etc (much like at the bottom of a google results page).
Here's an untested, top-of-head Python Script that assumes you pass in a variable called offset that defaults to 0. ---- records = context.your_zsql_method(args) batch_size = 5 last_record = min([offset+batch_size,len(records)]) for record_num in range(offset, last_record): print records[record_num]['some_info'] for page in range(0,len(results),batch_size): print '<a href=your_url?offset=%s>%s</a>' % (page,page/batch_size) return printed ----- It's incomplete and ugly, but should get you well on your way. HTH, Dylan