On Wednesday, January 4, 2012 4:15:51 PM UTC-5, Yarin wrote:
>
> Thanks guys, but for the record I know missing keys on request.vars 
> wasn't returning None in 1.99.2, and when I upgraded it broke my code. 
> Does anyone have an explanation?
>

>From Jonathan: 
https://groups.google.com/forum/#!msg/web2py/qe4v5TmlBHs/I9dvPB8uEDYJ

I guess the behavior you were relying on was considered a bug -- as Bruno 
pointed out, the documentation says:

"Unlike a dictionary, if an attribute (or key) does not exist, it does not 
raise an exception. Instead, it returns None. "

It doesn't indicate that there should be any difference between modes of 
access (i.e., .key vs. ['key']), so the change was made for consistency.

In your code, you could just do:

sort = request.vars.sort or 'created'

which I think would be an improvement in either case.

Anthony

Reply via email to