[Zope] newbie-ish dmtl-in question

Jim Washington jwashin@vt.edu
Sun, 26 Aug 2001 13:14:45 -0400


Russell Hires wrote:

>Hello everyone,
>
>I want to get a value from a form on one page to either a dtml-in variable or 
>dtml-unless variable on another page, which I seem to be able to do, but for 
>some reason I get no iteration. I'm able to send the variable over to the 
>other page just fine, but neither the dtml-in nor the dtml-unless wants to do 
>their thing. I'm using the Database connection examples from the Zope Book as 
>my examples, but I'm clearly not doing something right...
>
>On the page where I get my value from a form is this:
><form action="result-test" method="POST">
><input type="text" name="iterations:int">
><input type="submit" value="submit">
>
>and on the page I'm going to, I have this:
><dtml-in iterations>
>This is a test
></dtml-in>
>So, when I test, this is the error I get. I don't know what it means, 
>though...
>Error Type: TypeError
> Error Value: len() of unsized object
>
>How do I fix this?
>
Hi, Russell

<dtml-in> operates on list-ish things, which means it barfs on integers 
like your variable "iterations".
Fortunately, python to the rescue: "_.range(iterations)" makes a 
list-ish thing with "iterations" number of things from zero to 
"iterations -1".  Look in any python reference for range() if you need 
more, and check the zope docs, too because _.range() is limited in zope 
for a fairly obvious reason.

home, home on the range()

-- Jim Washington