Cherrypy acting up?

2 views
Skip to first unread message

prla

unread,
Jun 25, 2007, 5:53:51 PM6/25/07
to TurboGears
I'm developing a little mobile MIDP application which is supposed to
query a web app built using turbogears. The idea is to use the mobile
app to access something like http://<app url>/ and have it parse the
output (plain text should do it, the output is simple).

When using the regular desktop browser, the app loads fine but when I
go through the app, the output is This resource resides temporarily at
<a href='http://localhost:8080/'>http://localhost:8080/</a>.
Incidentally, that's exactly what happens when I try to use wget, for
instance: all I get is the HTML corresponding to the root of the app.
In both cases, thus, I get a 302.

Is this normal behavior? How then should I query the web server in
order to incorporate server data into the mobile app? Basically, this
is a grocery list which I want to able to download to mobile phones on
demand.

Thanks,

P.

Jorge Vargas

unread,
Jun 25, 2007, 8:55:14 PM6/25/07
to turbo...@googlegroups.com
what you are getting is a "redirect" or http "error code" 302 that
means what you are looking for is not here and it is in another place
(specified in headers), what is happening is that your "browser code"
isn't handling those and probably wget isn't either although I though
it did on the default configuration.

You may try several things the simplest will be to point to the full
resource and avoid the redirect, or you could have your client code
handle those. if you want to go the second way and your client code is
python take a look at
http://docs.python.org/lib/http-redirect-handler.html

on a side note why not set return_json=True instead of "parsing" the
page, if the message are small they are several APIs for it in almost
every popular language at json.org

> Thanks,
>
> P.
>
>
> >
>

Paulo André

unread,
Jun 26, 2007, 3:36:00 AM6/26/07
to turbo...@googlegroups.com
On Jun 26, 2007, at 1:55 AM, Jorge Vargas wrote:

what you are getting is a "redirect" or http "error code" 302 that
means what you are looking for is not here and it is in another place
(specified in headers), what is happening is that your "browser code"
isn't handling those and probably wget isn't either although I though
it did on the default configuration.

But why am I getting this redirect in the first place?

You may try several things the simplest will be to point to the full
resource and avoid the redirect, or you could have your client code
handle those. if you want to go the second way and your client code is
python take a look at

How should I go about "pointing to the full resource". I am trying to access http://localhost:8080/user/prla which is handled correctly on the web browser, but apparently not from the midlet code.

on a side note why not set return_json=True instead of "parsing" the
page, if the message are small they are several APIs for it in almost
every popular language at json.org

I'd love to do that, but unfortunately there's no facilities for parsing JSON on the (very) restricted MIDlet Java API (although there is on the full Java API, but I can't use that on the MIDlet code).

P.

Sylvain Hellegouarch

unread,
Jun 26, 2007, 3:40:56 AM6/26/07
to turbo...@googlegroups.com
Paulo André a écrit :

>
> On Jun 26, 2007, at 1:55 AM, Jorge Vargas wrote:
>
>> what you are getting is a "redirect" or http "error code" 302 that
>> means what you are looking for is not here and it is in another place
>> (specified in headers), what is happening is that your "browser code"
>> isn't handling those and probably wget isn't either although I though
>> it did on the default configuration.
>
> But why am I getting this redirect in the first place?

This is the normal behavior from CherryPy when you access the index page
handler of the application with a trailing '/', it will redirect you to
the correct URL with the trailing '/'. It works in your browser because
it understands the 302 and automatically performs the request at the
correct URL (look at your CP log).

So the question really is why not using the URL with the trailing '/' in
the first place? :)

- Sylvain

Paulo André

unread,
Jun 26, 2007, 3:43:43 AM6/26/07
to turbo...@googlegroups.com

On Jun 26, 2007, at 8:36 AM, Paulo André wrote:


On Jun 26, 2007, at 1:55 AM, Jorge Vargas wrote:

what you are getting is a "redirect" or http "error code" 302 that
means what you are looking for is not here and it is in another place
(specified in headers), what is happening is that your "browser code"
isn't handling those and probably wget isn't either although I though
it did on the default configuration.

But why am I getting this redirect in the first place?

I'm sorry, my bad... I just found out the culprit (a simple case of PEBKAC). In my controller I was raising a cherrypy redirect to "/" whenever authentication failed and that was why both the wget and my midlet were getting the 302, because they simply didn't authenticate.

Allow me while I go slap myself senseless...

P.

Sylvain Hellegouarch

unread,
Jun 26, 2007, 3:44:21 AM6/26/07
to turbo...@googlegroups.com
Sylvain Hellegouarch a écrit :

> Paulo André a écrit :
>
>> On Jun 26, 2007, at 1:55 AM, Jorge Vargas wrote:
>>
>>
>>> what you are getting is a "redirect" or http "error code" 302 that
>>> means what you are looking for is not here and it is in another place
>>> (specified in headers), what is happening is that your "browser code"
>>> isn't handling those and probably wget isn't either although I though
>>> it did on the default configuration.
>>>
>> But why am I getting this redirect in the first place?
>>
>
> This is the normal behavior from CherryPy when you access the index page
> handler of the application with a trailing '/',

Above I meant *without* the trailing '/'. Sorry.


Sylvain Hellegouarch

unread,
Jun 26, 2007, 3:45:29 AM6/26/07
to turbo...@googlegroups.com
Paulo André a écrit :


Er... that too...

- Sylvain

Reply all
Reply to author
Forward
0 new messages