On Sunday, April 29, 2012 7:54:11 PM UTC-4, Massimo Di Pierro wrote:
>
> I often run into this problem:
>
> def index():
>       record=db.tablename(request.args(0))  or redirect(URL('error'))
>
> which assumes request.args(0) is integer or missing. If not it issues a 
> ticket.
>

If request.args(0) is not an integer or missing, doesn't 
db.tablename(request.args(0)) simply return None -- in which case, no 
ticket should be issued? Also, you can already do request.args(0, 
default=0) if you want a 0 instead of None when request.args is empty, no?
 

> In trunk there is a new request.intargs which allows
>
> def index():
>       record=db.tablename(request.intargs(0,default=0)) or 
> redirect(URL('error'))
>
>
Another option might be:

request.args(0, assert_int=True, ...)

Anthony

Reply via email to