HTTPRedirect from a default handler

12 views
Skip to first unread message

ethilien

unread,
Nov 30, 2006, 11:30:31 PM11/30/06
to cherrypy-users
I am having a problem with HTTPRedirects from a default handler. Here's
my setup. I have a class called class called StudentController which is
sitting on my root handler under 'students'. All requests are going to
a default handler, which under certain circumstances will redirect to
another page which is also handled by this default handler. The problem
is that when I redirect, it takes me back to the root of the site.

For instance, the user first requests /students/. This raises an
HTTPRedirect to 'contact'. However, instead of taking the user to
/students/contact like I would expect it to, they are redirected to
/contact. I have tracked this problem down to the url function in
__init__.py. Apparently this function will automatically strip a
trailing slash from the current url if the call is not being handled by
an index function, which it isn't because its a default handler. This
causes the result of cherrypy.url (which is called in the HTTPRedirect
__init__ function) to return /students (note the lack of a trailing
slash). _urljoin then removes the 'students' part of the url, and the
end url is /contact.

Basically, I know exactly what the problem is and what is causing it,
but my question is whether or not this is supposed to happen. I'm
considering filing a bug regarding this, but I wanted to check first
that this isn't the desired behavior.

The way I consider fixing this issue is to make a default handler set
the is_index attribute on a request. This would make cherrypy.url keep
the trailing slash so that the redirect would work correctly.

I can write a patch to do this, I just need to make sure that this is a
bug.

Thanks,
Connor

fumanchu

unread,
Dec 1, 2006, 12:53:54 AM12/1/06
to cherrypy-users

This looks like a bug to me. A ticket would be great!


Robert Brewer
System Architect
Amor Ministries
fuma...@amor.org

Connor McKay

unread,
Dec 1, 2006, 2:43:26 PM12/1/06
to cherryp...@googlegroups.com
Hmm, maybe I'm just being dumb and can't find it, but I can't figure out how to create an account in the trac to submit a ticket. I keep just getting permission denied errors when I go to the newticket page...

Christian Wyglendowski

unread,
Dec 1, 2006, 2:45:45 PM12/1/06
to cherryp...@googlegroups.com
On 12/1/06, Connor McKay <ethi...@gmail.com> wrote:
Hmm, maybe I'm just being dumb and can't find it, but I can't figure out how to create an account in the trac to submit a ticket. I keep just getting permission denied errors when I go to the newticket page...

Log in as guest/cherrypy to create tickets.

Christian
http://www.dowski.com


Connor McKay

unread,
Dec 1, 2006, 3:46:07 PM12/1/06
to cherryp...@googlegroups.com
Bug submitted along with a patch.
Reply all
Reply to author
Forward
0 new messages