cloc3 wrote: > I'm a newbie in python, and I'm fighting against nested blocks in psp. > Thats a little example with a funny behaviour: > [code] > <html> > <form> > <select name="List"> > <!--makes a list with a loop --> > > <% > for i in range(50, 350, 50): > if 'List' in form and int(form['List'])==i: > sel="selected" > else: > sel="pippo" > %><option value="<%=i%>" <%=sel%> ><%=i%> </option> > <% > %> > </select> > <input type="submit" value="return"/> > </form> > </html> > [/code] > In my intention, the for instruction have to run two operation: > first: the if instruction > second: to print the option tag on the html page. > > Instead, the real behaviour is depending on the result of the control > in the if: > if the control is true, the option tag is not printed, and the for > instruction goes to the successive step. > if the control is false, the option is correctly printed. > > I don't understand the reason of this behaviour. > Which is the right way to control the nested block instructions in psp?
PSP as implemented by mod_python is fussy about how many spaces are used in indents. Use either 8 space or tab indents. If you don't want to do that, you will need to use comment hints to help PSP understand what level of indenting you are using. See: http://www.modpython.org/pipermail/mod_python/2005-May/018102.html Comment hints may still be needed in certain cases to turn off scopes even if 8 space or tab indents are needed so it is good to understand what they are about. Also ask further questions on mod_python user mailing list as you will in general get better responses there. Graham -- http://mail.python.org/mailman/listinfo/python-list