Re: [Zope] batching help
Thanks a lot , I did it with my 'ugly' way but that was exactly what I was looking for. cheers.. Martijn Pieters wrote: On 12/15/05, Nicolas Georgakopoulos [EMAIL PROTECTED] wrote: Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? Use batches and the following recipe: http://zopelabs.com/cookbook/998066576 -- Martijn Pieters ___ 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 )
Re: [Zope] batching help
On 12/15/05, Nicolas Georgakopoulos [EMAIL PROTECTED] wrote: Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? Use batches and the following recipe: http://zopelabs.com/cookbook/998066576 -- Martijn Pieters ___ 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 )
[Zope] batching help
Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? this is my code: table tal:define=Rnumber python:context.cm1.content.specialfile.getList('link_list') ; batch python:modules['ZTUtils'].Batch(Rnumber,size=3,start=0) th colspan=3Main Title/th trthTitle 1/ththTitle 2/ththTitle 3/th/tr tr td tal:repeat=num batch span tal:condition=python:num 3 tal:replace=structure num content goes here.. /span /td /tr !-- tr td tal:repeat=num batch span tal:replace=structure num Material goes here /span /td /tr -- /table ___ 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 )
Re: [Zope] batching help
Hi I suggest to use the following function that def get_grouped_list(self, seq=[], size=3): #get the list with all items grouped return [seq[i:i+size] for i in range(0, len(seq), size)] that takes as parameter a list and goups items in slices with length = size. def get_grouped_list(seq=[], size=3): ... return [seq[i:i+size] for i in range(0, len(seq), size)] ... l = [1,2,3,4,5,6,7,8] get_grouped_list(l) [[1, 2, 3], [4, 5, 6], [7, 8]] get_grouped_list(l, 4) [[1, 2, 3, 4], [5, 6, 7, 8]] Then iterating this is something like: tr tal:repeat=slice python:someobject.get_grouped_list(yourlist) td tal:repeat=item slice span tal:replace=item / /td /tr Hope this will help. Dragos Nicolas Georgakopoulos wrote: Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? this is my code: table tal:define=Rnumber python:context.cm1.content.specialfile.getList('link_list') ; batch python:modules['ZTUtils'].Batch(Rnumber,size=3,start=0) th colspan=3Main Title/th trthTitle 1/ththTitle 2/ththTitle 3/th/tr tr td tal:repeat=num batch span tal:condition=python:num 3 tal:replace=structure num content goes here.. /span /td /tr !-- tr td tal:repeat=num batch span tal:replace=structure num Material goes here /span /td /tr -- /table ___ 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 ) -- Dragos Chirila Programmer, Finsiel Romania (http://www.finsiel.ro) 44A, Ficusului St. - 013975 Bucharest Tel: +40 21 2320193, Fax: +40 21 2329807 Jabber: [EMAIL PROTECTED] ___ 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 )
Re: [Zope] batching help
Dragos Chirila wrote: Hi I suggest to use the following function that def get_grouped_list(self, seq=[], size=3): #get the list with all items grouped return [seq[i:i+size] for i in range(0, len(seq), size)] that takes as parameter a list and goups items in slices with length = size. def get_grouped_list(seq=[], size=3): ... return [seq[i:i+size] for i in range(0, len(seq), size)] ... l = [1,2,3,4,5,6,7,8] get_grouped_list(l) [[1, 2, 3], [4, 5, 6], [7, 8]] get_grouped_list(l, 4) [[1, 2, 3, 4], [5, 6, 7, 8]] Then iterating this is something like: tr tal:repeat=slice python:someobject.get_grouped_list(yourlist) td tal:repeat=item slice span tal:replace=item / /td /tr Hope this will help. Dragos Nicolas Georgakopoulos wrote: Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? this is my code: table tal:define=Rnumber python:context.cm1.content.specialfile.getList('link_list') ; batch python:modules['ZTUtils'].Batch(Rnumber,size=3,start=0) th colspan=3Main Title/th trthTitle 1/ththTitle 2/ththTitle 3/th/tr tr td tal:repeat=num batch span tal:condition=python:num 3 tal:replace=structure num content goes here.. /span /td /tr !-- tr td tal:repeat=num batch span tal:replace=structure num Material goes here /span /td /tr -- /table ___ 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 ) Thanks for your suggestion Dragos , I want to do it the zope batch way (I suppose it is simpler) if I can... I will keep in mind your function if nothing else can be done. Thanks again. ___ 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 )
Re: [Zope] batching help
Nicolas Georgakopoulos wrote: Dragos Chirila wrote: Hi I suggest to use the following function that def get_grouped_list(self, seq=[], size=3): #get the list with all items grouped return [seq[i:i+size] for i in range(0, len(seq), size)] that takes as parameter a list and goups items in slices with length = size. def get_grouped_list(seq=[], size=3): ... return [seq[i:i+size] for i in range(0, len(seq), size)] ... l = [1,2,3,4,5,6,7,8] get_grouped_list(l) [[1, 2, 3], [4, 5, 6], [7, 8]] get_grouped_list(l, 4) [[1, 2, 3, 4], [5, 6, 7, 8]] Then iterating this is something like: tr tal:repeat=slice python:someobject.get_grouped_list(yourlist) td tal:repeat=item slice span tal:replace=item / /td /tr Nicolas Georgakopoulos wrote: Hello all , I'm trying to display on the same page a table with (3 columns) with content from a list . I'm trying to batch the results so that every 3 elements anothe row is created. Can anyone give me a clue how to do that ? this is my code: table tal:define=Rnumber python:context.cm1.content.specialfile.getList('link_list') ; batch python:modules['ZTUtils'].Batch(Rnumber,size=3,start=0) th colspan=3Main Title/th trthTitle 1/ththTitle 2/ththTitle 3/th/tr tr td tal:repeat=num batch span tal:condition=python:num 3 tal:replace=structure num content goes here.. /span /td /tr !-- tr td tal:repeat=num batch span tal:replace=structure num Material goes here /span /td /tr -- /table Thanks for your suggestion Dragos , I want to do it the zope batch way (I suppose it is simpler) if I can... I will keep in mind your function if nothing else can be done. The ZTUtils batching is mostly for batching between pages. It's probably easier to do it in a Python script. --jcc -- Building Websites with Plone http://plonebook.packtpub.com/ Enfold Systems, LLC http://www.enfoldsystems.com ___ 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 )