CP2.2 beta redirect

2 views
Skip to first unread message

dimitri pater

unread,
Feb 6, 2006, 5:56:27 PM2/6/06
to cherryp...@googlegroups.com
Hello,
In CP2.1 I used to do:
import cherrypy
from cherrypy.lib import httptools
***more here
httptools.redirect('../news')
***more here

and it worked! But with CP2.2 beta:
import cherrypy
#from cherrypy.lib import httptools
***more here
cherrypy.HTTPRedirect('../news')
***more here
does not work, it returns to the same page
(no tracebacks in Eclipse/Pydev)
Could somebody please explain me why? I have searched for an answer and tried several things, to no avail...
thanks,
Dimitri


--
----
"All truth passes through three stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident."
~Arthur Schopenhauer
----
Please visit dimitri's website: www.serpia.org

Christian Wyglendowski

unread,
Feb 6, 2006, 7:31:09 PM2/6/06
to cherryp...@googlegroups.com
dimitri pater wrote:
> Hello,
> In CP2.1 I used to do:
> import cherrypy
> from cherrypy.lib import httptools
> ***more here
> httptools.redirect('../news')
> ***more here
>
> and it worked! But with CP2.2 beta:
> import cherrypy
> #from cherrypy.lib import httptools
> ***more here
> cherrypy.HTTPRedirect('../news')
> ***more here
> does not work, it returns to the same page
> (no tracebacks in Eclipse/Pydev)
> Could somebody please explain me why? I have searched for an answer and
> tried several things, to no avail...

Hi Dmitri,

Starting with 2.1, httptools.redirect() was deprecated in favor of the
*exception* cherrypy.HTTPRedirect. The correct way to do redirects in
2.1 and 2.2 is:

raise cherrypy.HTTPRedirect('/somewhere/else')

Christian

Istvan Albert

unread,
Feb 7, 2006, 10:47:42 AM2/7/06
to cherrypy-users
> httptools.redirect() was deprecated in favor of the *exception*

which, incidentally, is not a particulary good decision ...

The following workaround was suggested, write a helper function and
return that:

def redirect(url):
cherrypy.HTTPRedirect(url).set_response()
return cherrypy.response.body

dimitri pater

unread,
Feb 7, 2006, 2:28:42 PM2/7/06
to cherryp...@googlegroups.com
thank you, it works on the webserver
but not on localhost though,
it gets redirected to http://localhost/somepage
in stead of http://localhost:8080/somepage
but I guess that is easy to solve...
Thanks, Dimitri
Reply all
Reply to author
Forward
0 new messages