One good feature of storage object is the 'None' returned instead of KeyError.
By the way it does not break backwards compatibility because it is a documented feature[1] "Unlike a dictionary, if an attribute (or key) does not exist, it does not raise an exception. Instead, it returns None." The above statement is there for a long time and I guess storage always had this behaviour since I am using web2py. [1] http://web2py.com/books/default/chapter/29/4?search=gluon.storage On Tue, Jan 3, 2012 at 12:53 PM, Yarin <ykess...@gmail.com> wrote: > Having just upgraded from 1.99.2 to 1.99.4, I noticed that trying to > access a gluon.storage.Storage with a missing key no longer returns a > KeyError, but None. This broke my application due to the way I check > for request vars: > > try: > sort = request.vars['sort'] > except KeyError: > sort = 'created' > > When the 'sort' request var is missing, this code will now assign None > to sort instead of the default value. > > I could not find mention of this change or the reasoning behind it in > the change log. Can someone speak to this? My view is that making > gluon.storage.Storage key access behave differently from standard > Python dictionaries is confusing. -- Bruno Rocha [http://rochacbruno.com.br]