[ZPT] ZSQL Batchine

Jim Kutter jim@ebizq.net
Thu, 1 Aug 2002 14:41:07 -0400


Ah slices! Of course!=20

Thanks.

-jim
----- Original Message -----=20
From: "Joel Burton" <joel@joelburton.com>
To: "Jim Kutter" <jim@ebizq.net>
Cc: <zpt@zope.org>
Sent: Thursday, August 01, 2002 2:39 PM
Subject: Re: [ZPT] ZSQL Batchine


> On Thu, 1 Aug 2002, Jim Kutter wrote:
>=20
> > Hi folks
> >
> > I've looked high and low, and I can't find any examples how to run a
> > SQL query, batching the results from ZPT
> >
> > i have a query that returns like 50 items, I need them displayed in
> > two columns on a page, first 25 in one column, second 25 in the next
> > column. I've seen that in DTML using the start and size arguments to
> > the ZSQL method, but it befuddles me as to how to tell the ZSQL =
method
> > that stuff in ZPT.
> >
> > Does anyone know?
> >
> > -jim
>=20
> Simple setup:
>=20
> <div tal:define=3D"list here/sqlSelectMethod;">
>   <table>
>     <tr>
>       <td>
>         <p tal:repeat=3D"item python: list[:25]" =
tal:content=3D"item/colA" />
>       </td>
>       <td>
>         <p tal:repeat=3D"item python: list[25:]" =
tal:content=3D"item/colB" />
>       </td>
>     </tr>
>   </table>
> </div>
>=20
> This isn't batching per se -- normally, batching refers to displaying
> results over several pages. However, you could use this strategy with
> batching--just cut the returned batch in half, as above.
>=20
> This solution hard codes 25 as half the list size--you could instead =
cut
> the list by using len(list)/2.
>=20
> I have a small q&d script that cuts any list into n number of balanced
> sublists. Then, you can say define=3D"sublists =
python:listSplit(list,3)"
> to cut your list into 3 equal chunks, as sublist[0], sublist[1],
> sublist[2].
>=20
> HTH.
>=20
>  --
>=20
> Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: =
wjoelburton
> Independent Knowledge Management Consultant
>=20
>=20