[Zope] re: Length of results set

Dylan Reinhardt Dylan@DylanReinhardt.com
Thu, 16 Jan 2003 09:15:41 -0800


At 08:39 AM 1/16/2003, Ken wrote:
>Hi again,
>
>Maybe I'd better re-phrase my question. I think it will be easy for many 
>of you, maybe even me.. I had too much coffee last night.
>
>How do you get the length of results for a <dtml-if> inside a <dtml-in> ?
>
>It can't really have anything to do with <sequence-length>, and I've tried 
>a few ideas using "._len(...)" but to no avail.


It's _.len() not ._len()

The underscore is a namespace representing the current context.  You need 
to call len() as a method of that namespace.

You will also need to use the prefix attribute of <dtml-in> since you can't 
use "sequence-item" in a Python expression.

Do something like this:

<dtml-in some_sequence prefix="my_seq">
    <dtml-if "_.len(my_seq_item) > 5">
       It's bigger than five.
    <dtml-else>
       It's less than or equal to five
    </dtml-if>
</dtml-in>

HTH,

Dylan