Jim Gallacher
jg.lists at sympatico.ca
Wed May 11 14:39:58 EDT 2005
Wouter van Marle wrote: > Hi all, > > I've a problem using the psp functions. > What I am doing: > I've a psp page, using some in-line python code, in between <% and %> > tags as per many examples. I however get all the time syntax errors when > running this through the psp.PSP.run() function. I'm sure my python code > as such is correct, so I'm at a loss here. Some code: > > page.psp: > <html><head> > <!-- rest of the header and so --> > </head> > <p> some text for the page </p> > <% > for r in Results: > %> > I got the result <%=r%><br> > <% > # end indentation > %> > > then in my python program I have made a list Results, containing strings. > > page = psp.PSP(req, "page.psp") > page.run({"Results": Results}) > > When running it like that, in my browser an error message appears giving > a syntax error, pointing at the "for" in the loop. > > Now from the documentation I can not find anything that would forbid > this. I haven't tried to set up a psp handler in apache, as I do not > intend to use this as such. I want to be able to pass a list of results > to the page, and then have the page fill itself, as smart template. The > main code should be out of the page. > You found one of the warts in psp. Since your for loop contains no further python statements, the parser gets confused. Try adding a single comment at the beginning of your for loop: <p> some text for the page </p> <% for r in Results: # begin indentation - comment fixes the syntax error %> I got the result <%=r%><br> <% # end indentation %> Regards, Jim
|