[Zope] newbie question, #in tag
Martijn Pieters
mj@antraciet.nl
Mon, 12 Jul 1999 09:00:30 +0200
At 22:55 09/07/99 , Bruno Matarollo wrote:
> Well, let's get to the point. I have a form where I have an INPUT
>tag that is like this:
><INPUT TYPE="TEXT" NAME="cant" SIZE="3" MAXLENGTH="3">
>
>It is used to input a number... But in the DTML file used to process the
>form, I want to use a range where the max is the "cant" inputed at the
>INPUT tag... I have a <!--#in cant-->, but obviously Zope complains that
>strings cannot be used in 'in' tags... So, how do I do to iterate in
>asequence that starts on 1 and ends on 'cant'? On python I would create a
>list but I don't know how to do this using only DTML methods. Is it
>possible?
In python you'd use the range() method, but that method is not available in
Zope, at least, not in version 1.x. Zope 2 does include a range method,
it's a member of the _ object. You would use it like this:
<!--#in "_.range(1, cant)"-->
In Zope 1.x, you'll have to create an external method that returns the
result of the python range method for you:
def MyRange(iMax):
return range(1, iMax)
and call it from your in tag:
<!--#in "MyRange(iMax=cant)"-->
Note: Above code is untested. YMMV.
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------