After some hours of digging, I discovered why this small script
worked erratically:

[% USE q=CGI %]
[% a = q.param('xx') %]
[% a.push(3) %]
[% a.join(',') %]

it behaves differently if it is called as 

1) http://myserver/myscript.tt2
2) http://myserver/myscript.tt2?xx=2
3) http://myserver/myscript.tt2?xx=2&xx=4

since q.param in the first case  returns empty, in the second a scalar and 
in the third a list. In this case it does not work in case 1,2

replacing the second line of the script with 

[% a = q.param('xx').list %]

it works in case 2,3 and not in case 1.

The only way I find to have it working in all cases is to replace line 2 
with

[% a=[]; FOREACH x = q.param('xx'); a.push(x); END %]

This should be written in the help pages. 

Maybe there is a simpler way? Or should the "list" virtual method return
an empty list when called with a void argument? 



-- 
Franco Bagnoli (franchino) <[EMAIL PROTECTED]> ([EMAIL PROTECTED])
virtual location: Dipartimento di Energetica "S. Stecco"
ultra-virtual affiliation: Centro Dinamiche Complesse (CSDC-Firenze)
real location: Dip. Matematica Applicata "G. Sansone", Universita' Firenze,
Via S. Marta, 3 I-50139 Firenze, Italy. Tel. +39 0554796422, fax: +39 055471787



_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to