How i can use? def mycaller(f): try: return f() except *(HTTP...)* : return f() else: raise(HTTP(400))
Vào 09:09:50 UTC+7 Thứ năm, ngày 17 tháng năm năm 2012, IVINH đã viết: > > > Thanks. > > I'm try: > > def mycaller(f): > try: return f() > except: raise(HTTP(400)) > > response._caller = mycaller > > But it's break my redirect in controller. > > > Vào 08:47:14 UTC+7 Thứ năm, ngày 17 tháng năm năm 2012, Anthony đã viết: >> >> def index(): >>> try: >>> redirect(URL(f='user',args=['login'])) >>> except: raise HTTP(400) >>> >> >> redirect() is equivalent to raising an HTTP(303) exception, but of >> course, the exception you are raising in the try is actually caught by your >> except, so it ends up raising the HTTP(400) exception instead. >> >> Anyway, what are you trying to do? You can just redirect to /user/login, >> and if there is a problem with that request, the framework will raise its >> own 404 (or 500) error. >> >> Anthony >> >