[Zope] Difference between dtml-let & dtml-in

Jean Lagarde jlagarde@bigfoot.com
Thu, 24 Jan 2002 07:08:50 -0800


I wouldn't call me a Zope expert yet, but I'm pretty sure that I know 
what is going on. In your dtml-let, sql is not set to the RESULT of 
calling the zsqlmethod, but to a REFERENCE to the method (and Python 
does not complain about that). The method is subsequently called in your 
dtml-in tag (you don't need the brackets because you called it with the 
variable syntax; if you use the expression syntax instead (sql in double 
quotes), you should get the same error). In the second case, collapsed 
to the dtml-in, you are using the expression syntax, so you need the 
brackets.

Cheers,

Jean

On 23 Jan 02, Gabriel Genellina wrote:

> Hi
>
> This piece of code works fine:
>
> <dtml-let sql="restrictedTraverse(PathToSqlMethod)">
> <dtml-in sql>
> <dtml-var AnyFieldName>,
> </dtml-in>
> </dtml-let>
>
> where PathToSqlMethod is a path to any SQLMethod, and AnyFieldName is a
> column name in that SQLMethod.
>
> Then, I didnt like the dtml-let, so I collapsed both lines, and wrote:
>
> <dtml-in "restrictedTraverse(PathToSqlMethod)">
> <dtml-var AnyFieldName>,
> </dtml-in>
>
> and I got a KeyError in __getitem__, Error Value: 0 (zero).
> After several attempts I got the right way of doing it:
>
> <dtml-in "restrictedTraverse(PathToSqlMethod)()">
> <dtml-var AnyFieldName>,
> </dtml-in>
>
> So I need to call the SQLMethod explicitly, and then it returns a 
> sequence
> that <dtml-in> can handle (at least, this is what I guess.)
>
> But now, I don't understand why the ()'s arent needed using 
> <dtml-let>, and
> then, why are them really necessary using <dtml-in "">.
> I would expect both tags to behave similarly.
> Perhaps someone can explain me the difference.
>
>
> Gabriel Genellina
> Softlab SRL