HTTPRedirect from a default handler

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTPRedirect from a default handler

ethilien-2

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


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: HTTPRedirect from a default handler

Robert Brewer

ethilien wrote:

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

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


Robert Brewer
System Architect
Amor Ministries
[hidden email]


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: HTTPRedirect from a default handler

ethilien-2
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...

On 11/30/06, fumanchu <[hidden email]> wrote:

ethilien wrote:

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

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


Robert Brewer
System Architect
Amor Ministries
[hidden email]






--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: HTTPRedirect from a default handler

Christian Wyglendowski-2
On 12/1/06, Connor McKay <[hidden email]> 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



--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: HTTPRedirect from a default handler

ethilien-2
Bug submitted along with a patch.

On 12/1/06, Christian Wyglendowski <[hidden email]> wrote:
On 12/1/06, Connor McKay <[hidden email]> 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
<a href="http://www.dowski.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.dowski.com






--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---