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

Christian S. Perone christian.perone at gmail.com
Thu Apr 26 08:11:53 EDT 2007


Well, in my mind, it's a programming bad practice, cause aborting the flow
of program can make it hard to maintain and debug by creating multiple
exit points, some use the maxim "one way in and one way out",
and this is true and specifically important inside loops. But the point is
that: this must
be avoided by programmer, not in the language. I think that will be
a nice feature in mod_python, the syntax can be like in myghty templating
system: request.abort(status_code=None), and can be implemented using
the approach that Mike said.
It's just a suggestion, thank you for help.

- Christian S. Perone

On 4/26/07, Mike Looijmans <nlv11281 at natlab.research.philips.com> wrote:
>
> 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
> >
> >
> >
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



-- 
Christian S. Perone - christian_perone at gmail dot com
"The effect of music is so very much more powerful and penetrating than is
that of the other arts, for these others speak only of the shadow, but music
of the essence."
- Schopenhauer, Vol. I, Chapter III, The World As Representation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070426/f8547b59/attachment.html


More information about the Mod_python mailing list