#1128: turbogears.redirect() incorrectly used
-------------------------------------+--------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: unassigned | Version: 1.0b1
Severity: normal | Keywords:
-------------------------------------+--------------------------------------
Tutorial and code generated by quickstart use turbogears.redirect() like
this
{{{
raise turbogears.redirect(url)
}}}
but regarding the function source, the correct use is just a call to the
function
{{{
turbogears.redirect(url)
}}}
The source of the function in /site-packages/TurboGears-1.0b1-
py2.4.egg/turbogears/controllers.py is
{{{
def redirect(redirect_path, redirect_params=None, **kw):
"""Redirect (via cherrypy.HTTPRedirect)."""
raise cherrypy.HTTPRedirect(
url(tgpath=redirect_path, tgparams=redirect_params,
**kw))
}}}
of course the current use is working but it's usage is not correct.
It's better to show the '''raise''' in the source code to let the user
keep in mind the flow of the program is changing.
The simple function call will hide the flow disturbance.
Changing the '''raise''' by a '''return''' in the function will do the
trick
Then I suggest to replace the function definition by :
{{{
def redirect(redirect_path, redirect_params=None, **kw):
"""A shortcut for cherrypy.HTTPRedirect."""
return cherrypy.HTTPRedirect(
url(tgpath=redirect_path, tgparams=redirect_params,
**kw))
}}}
for more info look
[http://groups.google.com/group/turbogears/browse_frm/thread/35033ba7f3126d9a/01d3f86543708a4e#01d3f86543708a4e]
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1128>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---