Thank you, it worked! Yo'av
On Jan 8, 1:04 am, Christoph Zwerschke <[email protected]> wrote: > Am 05.01.2010 16:38 schrieb Yo'av Moshe: > > > I got this code in my controllers/root.py: > > > def _cp_on_http_error(self, status, message): > > print int(status) > > if int(status)==404: > > raise redirect("/one") > > else: > > raise redirect("/two") > > > As you can probably guess, what I want is that 404 errors will > > redirect to one page and all other error will redirect to another. But > > it won't work... > > I guess the problem is that raising a redirect exception will call > _cp_on_http_error() recursively and (only) an internal error will break > that recursion. So instead of raising an exception, I suggest you just > call it to modify the response. Also, you should call the default > _cp_on_http_error() function in your own function. Like this: > > def _cp_on_http_error(self, status, message): > cherrypy._cputil._cp_on_http_error(status, message) > url = "/one" if int(status) == 404 else "/two" > redirect = cherrypy.HTTPRedirect(url) > redirect.set_response() > > -- Christoph
-- You received this message because you are subscribed to the Google Groups "TurboGears" 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?hl=en.

