[mod_python] using nested blocks in psp

Graham Dumpleton grahamd at dscpl.com.au
Mon Jun 12 05:00:07 EDT 2006


Whoops. Yes the "#end if", not "#end for" as I mentioned.

Not enough sleep the last couple of days. ;-)

BTW, I had already sent this person the link:

   http://www.modpython.org/pipermail/mod_python/2005-May/018102.html

which exhibits indent hinting.

Graham

On 12/06/2006, at 6:51 PM, Mike Looijmans wrote:

> The way your code looks in my mailer, the indentation is flawed.
>
> It should be like this (indenting the HTML is not needed but makes  
> it better readable):
>
> ...
> <select name="Elenco">
> <%
> for i in range(50, 350, 50):
>     if 'Elenco' in form and int(form['Elenco'])==i:
>         sel='selected'
>     else:
>         sel=''
>     # end if
> %>
>     <option value="<%=i%>" <%=sel%> >
>     <%=i%>
>     </option>
> <%
> # end for
> %>
> </select>
> <input type="submit" value="acquisizione"/>
> ...
>
>
> Mike Looijmans
> Philips Natlab / Topic Automation
>
>
> ziapannocchia at gmail.com wrote:
>> In the code at the and of the post, the for instruction flux depends
>> from the nested if.
>> Behaviour expected: for any item, the for instruction executes the if
>> instruction and
>> write the option tag.
>> Real behaviour: the for instruction runs well only if the control in
>> the if instruction fails. If the control is true, the flux jumps  
>> to the
>> next item and the option tag is not printed on html output.
>> I need to understand if that depends from a bad indentation or if
>> structures with more than one ":" are not supported in psp.
>> Sorry for my english.
>> [code]
>> <html>
>> <form>
>> <select name="Elenco">
>> <!--genera elenco usando un loop -->
>> <%
>> for i in range(50, 350, 50):
>> if 'Elenco' in form and int(form['Elenco'])==i:
>>  sel='selected'
>> else:
>>  sel=''
>>  #
>> %>
>> <option value="<%=i%>" <%=sel%> >
>>  <%=i%>
>> </option>
>> <%
>> %>
>> </select>
>> <input type="submit" value="acquisizione"/>
>> </form>
>> </html>
>> [/code]
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list