[mod_python] psp problem

Jim Gallacher jg.lists at sympatico.ca
Wed May 11 22:33:46 EDT 2005


Wouter van Marle wrote:
> On Wed, 2005-05-11 at 14:39 -0400, Jim Gallacher wrote:
> 
>>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
>>%>
> 
> 
> Still the same problem, Jim.
> I've also tried with comment before the 'for' statement, doesn't make
> any difference :(
> 
> Wouter.
> 

Actually, I was using the comment after the for statement to fix a
slightly different problem. I've tested the snippet for the psp page you 
posted before and it works for me. Perhaps you could post the actual 
traceback?

Regards,
Jim




More information about the Mod_python mailing list