[Zope] Re: formatting the results of Zsql methods

garry saddington garry at joydiv.fsnet.co.uk
Sun Sep 26 14:13:43 EDT 2004


> 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.
Thanks, this works but then I would have to slice up the dictionaries to get 
at the individual values, so I have come up with this. Can anyone see a 
problem with it or could I do it more simply?

<dtml-in getclasses>
<dtml-if expr="_['sequence-number'] < 7">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var 
abbreviation>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<dtml-elif expr="_['sequence-number'] ==7">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var abbreviation><br><br>

<dtml-elif expr="_['sequence-number'] in range(8,14)">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var 
abbreviation>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<dtml-elif expr="_['sequence-number'] ==15">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var abbreviation><br><br>

<dtml-elif expr="_['sequence-number'] in range(16,22)">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var 
abbreviation>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<dtml-elif expr="_['sequence-number'] ==23">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var abbreviation><br><br>

<dtml-elif expr="_['sequence-number'] in range(24,30)">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var 
abbreviation>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<dtml-elif expr="_['sequence-number'] ==31">
<input type="checkbox" name="allocation.classid:records" value="<dtml-var 
classid>">
<dtml-var year><dtml-var teachgroup><dtml-var abbreviation><br>
 </dtml-if>
</dtml-in>

regards
garry


More information about the Zope mailing list