[Zope] Re: formatting the results of Zsql methods

Tres Seaver tseaver at zope.com
Sat Sep 25 20:09:19 EDT 2004


garry saddington wrote:
> I can iterate over the result set from a Zsql method and have each result 
> display across the page and wrap at the page border or I can have them 
> display down the page. I can't work out how to have say five across the page 
> and then have multiple rows each with five results. Could anyone point me in 
> the right direction?

A PythonScript is your friend, here.

   ##Script (Python) "inRows"
   ##title=Chunk a list into equal-length sub-lists
   ##parameters=source, chunk_size=5
   #
   result = []
   for start in range(0, len(source), chunk_size):
       result.append(source[start:start+chunk_size])
   return result

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope mailing list