Questions about cherrypy.request.object_path

70 views
Skip to first unread message

pytrade

unread,
Jul 7, 2006, 4:21:49 PM7/7/06
to cherrypy-users
I'm using cherrypy.request.object_path to get the current url
(including after an internal redirect). The problem is that it just
shows the url and not the variables

For instance:

If the current url after an internal redirect is:

http://domain/servlet/action.py?customerId=100

cherrypy.request.object_path just shows:
http://domain/servlet/action.py

How can I get the entire url after an internal redirect:
http://domain/servlet/action.py?customerId=100

Thanks,

Vineet

Christian Wyglendowski

unread,
Jul 7, 2006, 4:28:14 PM7/7/06
to cherryp...@googlegroups.com
On 7/7/06, pytrade <vinj...@gmail.com> wrote:

[snip]

How can I get the entire url after an internal redirect:
http://domain/servlet/action.py?customerId=100

Well, you can grab the value from cherrypy.request.query_string.  That should give you everything after the ? (question mark).  However, the internal redirect doesn't change the actual URL that is visited - it's internal.

Christian

Robert Brewer

unread,
Jul 7, 2006, 5:05:38 PM7/7/06
to cherryp...@googlegroups.com
pytrade wrote:
> I'm using cherrypy.request.object_path to get the current url
> (including after an internal redirect). The problem is that it just
> shows the url and not the variables
>
> For instance:
>
> If the current url after an internal redirect is:
>
> http://domain/servlet/action.py?customerId=100
>
> cherrypy.request.object_path just shows:
> http://domain/servlet/action.py
>
> How can I get the entire url after an internal redirect:
> http://domain/servlet/action.py?customerId=100

request.browser_url should do the trick for "before the redirect". But I
can't figure how "URL after an InternalRedirect" has any meaning, since
you're not telling the client anyway. If you want to notify the client
of a redirected URL, use HTTPRedirect; that's exactly what it's for.


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

pytrade

unread,
Jul 7, 2006, 10:47:10 PM7/7/06
to cherrypy-users
>> But I
can't figure how "URL after an InternalRedirect" has any meaning

I'll try and give you an example. On each page I have a resize option
which will adjust the page size based on your browser. Similar to what
yahoo has. This javascript function sets the appropriate value in the
user session and redisplays the current page. The url for the current
page is retrieved now by doing (thanks to Christian's suggestion)

cherrypy.request.object_path+"?"+cherrypy.request.query_string

Reply all
Reply to author
Forward
0 new messages