[ZPT] Re: Add 'parity' to repeat?

Charlie Clark charlie at begeistert.org
Thu Aug 28 12:16:40 EDT 2003


On 2003-08-27 at 18:35:21 [+0200], you wrote:
> Another usable idiom is indexing:
> 
> <table tal:define="classes python:('one', 'two', 'three')">
>    <tr tal:define="i repeat/row/index"
>        tal:attributes="class python:classes[i % 3]">
> 
> At least in Plone, though, simple even/odd alternation is *everywhere*.

But Zope isn't Plone. I've started looking at CMF and Plone for my current 
project but they are not where I am thinking. I can't be the only one like 
this. Twisting ZPT to suit Plone's needs reminds me of the comments I've 
heard from people about twisting Python for Zope's needs: brings benefits 
but not to all.

Let us try and find out what the real problem is and see if we can find a 
solution that is palatable (sic) to us all. As I understand it you are 
looking for a TALES *expression* to make dealing with alternation even more 
comfortable than it already is for non-Pythoneers. This is a valid 
suggestion as alternation clearly is a purely presentation issue and using 
dictionary dispatching or indexing, while wonderfully useful and powerful, 
are not immediately apparent to non-Pythoneers.

Alternation can be seen as either binary: either this or that; or as 
periodical. The first definition brings us to <tal:if><tal:else></tal:if> 
pretty quickly I think and we know where that discussion leads. 
<tal:condition> is sufficient when combined with <tal:define>

The second definition seems to be me more generally applicable: from 
alternating row colours to batching. If a change is necessary then I would 
prefer one that is based on this, i.e. makes your suggestion possible 
directly in TALES: define intervals in a sequence and allow actions to 
occur based on these intervals.

tal:define="red repeat/interval/3; blue repeat/interval/2; green 
repeat/interval/1"

tal:attributes="color interval"

I think I've got this back to front but I hope the point is coming across. 
I think I could live this quite happily.

Now: please point out the errors in my thinking before commenting on the 
implementation as I haven't really got a clue about that.

Charlie



More information about the ZPT mailing list