In tutorial and code generated by quickstart I see
raise turbogears.redirect(url)
but turbogears.redirect(url) is already a call to raise
cherrypy.HTTPRedirect(url) !
def redirect(redirect_path, redirect_params=None, **kw):
"""Redirect (via cherrypy.HTTPRedirect)."""
raise cherrypy.HTTPRedirect(
url(tgpath=redirect_path, tgparams=redirect_params,
**kw))
I thing the good use is just a call to turbogeard.redirect() and not to
use a raise !
Both will do about the same, but why not do it correctly ?
any comment ?
Best regards
Alain
> Best regards
>
> Alain
>
>
> >
>
So why no just return the object (replace the raise by a return)
def redirect(redirect_path, redirect_params=None, **kw):
"""Redirect (via cherrypy.HTTPRedirect)."""
return cherrypy.HTTPRedirect(
url(tgpath=redirect_path, tgparams=redirect_params,
**kw))
That way the correct usage is now :
raise turbogear.redirect(url)
as like used in tutorial and quickstart generated code.
if you can supply a patch or just tell files/line numbers so we can
look into it closely there may be a reason we are ommiting here.
This was a "bikeshed" moment from a few months ago. The code should
probably have a comment.
Some people thought that raise felt wrong and wanted to just call a
function. Many others, myself included, liked raise because it was
clearest that control flow is leaving your method immediately. Having
the raise in the redirect function didn't hurt the preferred use
"raise turbogears.redirect(...)" and still allowed the people who
didn't like the raise to do what they wished "turbogears.redirect(...)".
Kevin
It has a comment about it now :)
> Some people thought that raise felt wrong and wanted to just call a
> function. Many others, myself included, liked raise because it was
> clearest that control flow is leaving your method immediately. Having
> the raise in the redirect function didn't hurt the preferred use
> "raise turbogears.redirect(...)" and still allowed the people who
> didn't like the raise to do what they wished "turbogears.redirect(...)".
>
> Kevin
>
> >
>
--
cheers
elvelind grandin
>
> On 9/27/06, Kevin Dangoor <dan...@gmail.com> wrote:
>> This was a "bikeshed" moment from a few months ago. The code should
>> probably have a comment.
>
> It has a comment about it now :)
thanks!