[mod_python] PSP (exit/quit/return statement)

Mike Looijmans nlv11281 at natlab.research.philips.com
Thu Apr 26 01:20:56 EDT 2007


Raising an exception will get you there, with some help. If you wrap 
your PSP page in a publisher handler, you can create a "Abort" exception 
class that you catch silently.

class Abort(Exception): pass

try:
   PSP...
except Abort:
   pass
except:
   ... normal handling...


Mike Looijmans
Philips Natlab / Topic Automation


Graham Dumpleton wrote:
> On 25/04/07, Christian S. Perone <christian.perone at gmail.com> wrote:
> 
>> Hello, there is an exit, quit, abort or return like statement for psp ?
>> For example, I want to do that:
>>
>> <%
>> req.write("1")
>> [exit statement]
>> req.write("2")
>> %>
>>
>> in a way that the statement abort the flow of execution and the result 
>> be:
>> 1
>>
>> I have been read the documentation and don't found anything like that.
> 
> 
> There is no way to currently do it.
> 
> Some may argue that it is bad practice, but other templating systems
> do have such a feature.
> 
> Propose a syntax or mechanism for doing it and if others think it is
> reasonable it can be added to list of issues to be looked at.
> 
> Graham
> _______________________________________________
> 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