Another common application of sequences involves using them in combination with database result sets to break up a large result set into smaller batches.
Consider the following example, which invokes a ZSQL Method (for the uninitiated, a ZSQL Method is a special Zope object that allows you to communicate with a database - read more about it at (http://www.devshed.com/Server_Side/Zope/ZopeWithApache). In the following example, the GetUsers() method retrieves a list of users from a database
select * from person
as a sequence and uses a DTML loop to iterate through it and print the data.
The output displays all the records in a single page, as shown below.
This example uses the <dtml-in> tag to loop over the result set returned by the GetUsers() ZSQL Method. The rest of the code is good ol' HTML to make the page look pretty.
Depending on the number of records in the table, you can rest assured that this is a definite no-no as far as the usability and performance of the site is concerned. A better idea would be to split this result set into multiple "pages", so as to reduce overhead and also to make the site more usable. Here's the code: