WEb.py 0.3 bug/... ?

3 views
Skip to first unread message

skp_999

unread,
Nov 24, 2008, 3:30:39 AM11/24/08
to web.py
My web application run 100% OK with webpy 0.23 but when I upgraded to
0.3 (following upgrade guide) my app run "@ 50%". Sometimes, even with
simple functions, the app run ok then it suddenly dies with a Python
error. Example:
http://example.com/search/apple -> OK
http://example.com/search/python -> dies
http://example.com/search/orange -> OK
http://example.com/search/orang -> dies
(note that that my code works fine with .23)

the last part of Python error (it seems also that .30 doesn't see
app.internalerror = web.debugerror ) is:

197 except:
198 print >> web.debug, traceback.format_exc()
199 raise self.internalerror()
200
201 try:
self = <web.application.application instance at 0x8c9fc8c>,
self.internalerror = <function debugerror at 0xb7c66304>

<type 'exceptions.TypeError'>: exceptions must be classes, instances,
or strings (deprecated), not TemplateResult

How can I fix it ?

TheBoff

unread,
Nov 24, 2008, 6:42:43 AM11/24/08
to web.py
Try replacing print >> web.debug, traceback.format_exc() with
print >> web.debug, str(traceback.format_exc())

It might provide a better traceback at least: I'm not sure what you
mean by @50% : a paste bin of your code and how to reproduce the error
might be more useful.

On Nov 24, 8:30 am, skp_999 <scar...@gmail.com> wrote:
> My web application run 100% OK with webpy 0.23 but when I upgraded to
> 0.3 (following upgrade guide) my app run "@ 50%". Sometimes, even with
> simple functions, the app run ok then it suddenly dies with a Python
> error. Example:http://example.com/search/apple-> OKhttp://example.com/search/python-> dieshttp://example.com/search/orange-> OKhttp://example.com/search/orang-> dies

skp_999

unread,
Nov 24, 2008, 9:54:09 AM11/24/08
to web.py


On 24 Nov, 12:42, TheBoff <theb...@gmx.com> wrote:
> Try replacing print >> web.debug, traceback.format_exc() with
> print >> web.debug, str(traceback.format_exc())
>
> It might provide a better traceback at least: I'm not sure what you
> mean by @50% : a paste bin of your code and how to reproduce the error
> might be more useful.
>

SOLVED! The problem was in this part of code:

class myclass:
def GET(self, tags = ""):
input = web.input(p = 1)
mytxt = mysearch().search(tags, myutils.intget(input.p, 1))
web.header("Content-Type", "text/html; charset=utf-8")
return mytxt

mysearch().search(....) must have a string as first argument. I
noticed that 'tags' was not a string. If I replace

mytxt = mysearch().search(tags, myutils.intget(input.p, 1))
WITH:
mytxt = mysearch().search(str(tags), myutils.intget(input.p, 1))

everything is OK. Why :) ?

ps app.internalerror = web.debugerror doesn't work for me

bye

Anand Chitipothu

unread,
Nov 24, 2008, 10:08:41 AM11/24/08
to we...@googlegroups.com
>
> mytxt = mysearch().search(tags, myutils.intget(input.p, 1))
> WITH:
> mytxt = mysearch().search(str(tags), myutils.intget(input.p, 1))
>
> everything is OK. Why :) ?

because now web.input() returns unicode values.

> ps app.internalerror = web.debugerror doesn't work for me

it is set to debugerror if web.config.debug is set to True.
If you want custom notfound message, see:
http://webpy.org/cookbook/custom_notfound

Looks like it is not straight forward to set internalerror to
debugerror when web.config.debug=True.

This is how it should be done:

def debugerror():
return web.notfound(web.djangoerror())

app.internalerror = debugerror

Looks like web.debugerror and web.emailerrors should change to return
instance of web.notfound error.

Anand Chitipothu

unread,
Nov 24, 2008, 10:10:39 AM11/24/08
to we...@googlegroups.com
> This is how it should be done:
>
> def debugerror():
> return web.notfound(web.djangoerror())
>
> app.internalerror = debugerror
>
> Looks like web.debugerror and web.emailerrors should change to return
> instance of web.notfound error.
>

Oops. it should be internalerror, not notfound.

def debugerror():
return web.internalerror(web.djangoerror())

app.internalerror = debugerror

skp_999

unread,
Nov 24, 2008, 10:24:31 AM11/24/08
to web.py
Ok, now it works. If you want you can update the '0.2 -> 0.3 upgrade
guide' to state that now "web.input() returns unicode values." :)

bye, tnx

Anand Chitipothu

unread,
Nov 24, 2008, 10:34:22 AM11/24/08
to we...@googlegroups.com
> Ok, now it works. If you want you can update the '0.2 -> 0.3 upgrade
> guide' to state that now "web.input() returns unicode values." :)

Done!

skp_999

unread,
Nov 25, 2008, 3:22:06 AM11/25/08
to web.py
A note: you should also state that any variable in web.ctx.env and
'myvar' in

def GET(self, myvar = ""):
return myvar

are now unicode. It seems that _unicode=False only overrides
web.input ... or not ?

tnx for your work
Reply all
Reply to author
Forward
0 new messages