[Zope] re: Length of results set

Dylan Reinhardt zope@dylanreinhardt.com
Thu, 16 Jan 2003 10:29:29 -0800


At 09:54 AM 1/16/2003, you wrote:
>Dylan, thanks for trying...
>
> >It's _.len() not ._len()
>
>Right of course, sorry for the typo.
>
>It's not the total sequence-length that I am after, rather the number of 
>matches found by a <dtml-if> nested in a <dtml-in>.
>
> > <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE','en-us')">
> > <dtml-in objectValues>
> > <dtml-let folder=id>
> > <dtml-let langShort=lang[2:]>
> > <dtml-var langShort>
> > <dtml-if expr="folder==lang">
> > <dtml-var lang>  <---------- how many of these?
> > </dtml-if>                   (there could be several)
> > </dtml-let>
> > </dtml-let>
> > </dtml-in>
> > </dtml-let>


Uh... you're going to evaluate the length of lang, but only if it's equal 
to folder, which has been set equal to id?

I'm having trouble seeing how this could represent anything useful.

For starters, you've got a (probable) typo in your let tag... you need 
quotes if you're setting langShort equal to the value of an expression.  As 
more of a style thing, is lang actually an attribute of your object manager 
items or is it set elsewhere?  There's no need to put it in the loop if 
it's acquired prior to the loop.

Assuming that lang is acquired elsewhere, do you mean this:

<dtml-let langShort="lang[2:]">                <---- use quotes here
   <dtml-in objectValues>
     <dtml-if "id==langShort">                    <---- why bother with 
"folder" at all?
       Len of lang: <dtml-var "_.len(lang)"><BR>
       Value of langShort = <dtml-var langShort><P>
     </dtml-if>
   </dtml-in>
</dtml-let>

Getting warmer?

Dylan