Hello,
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...

When a page of mine got an error, i can see '500' and the traceback in
the console, and the browser is redirect to /two. But when I try to
get page which doesn't exist, it starts with an 404 error and than
becomes a 500 error, still redirecting me to /two instead of /one.

See this log:

404
Traceback (most recent call last):
  File "/Users/user/Projects/web/pyenv/lib/python2.6/site-packages/
cherrypy/_cphttptools.py", line 121, in _run
    self.main()
  File "/Users/user/Projects/web/pyenv/lib/python2.6/site-packages/
cherrypy/_cphttptools.py", line 256, in main
    page_handler, object_path, virtual_path = self.mapPathToObject
(path)
  File "/Users/user/Projects/web/pyenv/lib/python2.6/site-packages/
cherrypy/_cphttptools.py", line 326, in mapPathToObject
    raise cherrypy.NotFound(objectpath)
NotFound: (404, "The path '/nosuchpage' was not found.")

500
Traceback (most recent call last):
  File "/Users/user/Projects/web/pyenv/lib/python2.6/site-packages/
cherrypy/_cphttptools.py", line 134, in _run
    inst.set_response()
  File "/Users/user/Projects/web/pyenv/lib/python2.6/site-packages/
cherrypy/_cperror.py", line 173, in set_response
    handler(self.status, self.message)
  File "/Users/user/Projects/web/web/webtg/controllers/root.py", line
57, in _cp_on_http_error
    raise redirect("/calendar")
  File "/Users/web/Projects/web/pyenv/lib/python2.6/site-packages/
turbogears/controllers.py", line 754, in redirect
    tgparams=redirect_params, **kw))
HTTPRedirect: (['http://localhost:8080/one'], 302)

::1 - - [05/Jan/2010:15:31:04 +0000] "GET /nosuchpage HTTP/1.1" 302
121 "" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-US)
AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.49 Safari/532.5"
::1 - - [05/Jan/2010:15:31:04 +0000] "GET /two HTTP/1.1" 200 5832 ""
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-US) AppleWebKit/
532.5 (KHTML, like Gecko) Chrome/4.0.249.49 Safari/532.5"

Of course, /one is fully working when redirecting from anything else
on my application.

Can anyone shade some light over this?

Thank you.
Yo'av

--

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.


Reply via email to