Anthony, thank you.

I get it now.  I somehow thought these two are equivalent:

session[request.controller].something = 'foo'
session[request.controller]['something'] = 'foo'

Obviously they aren't.

On Feb 10, 8:41 am, Anthony <[email protected]> wrote:
> > # I think this should work:
> > if 'column_select_value' in session[request.controller].keys():
> >         column_select_value =
> > session[request.controller].column_select_value
>
> > # But I get this:
> > AttributeError: 'dict' object has no attribute 'column_select_value'
>
> In Python, you cannot access dict items that way -- it would have to be:
>
> session[request.controller]['column_select_value']
>
> Or you could do:
> from gluon.storage import Storage
> session[request.controller] = Storage()
>
> Then you can use session[request.controller].column_select_value, and you
> don't even have to test whether "column_select_value" is one of the keys --
> Storage objects simply return None when you try to access a key that
> doesn't exist.
>
> Also, side note -- with a Python dict, instead of "if 'mykey' in
> mydict.keys()" you can just do "if 'mykey' in mydict".
>
> Anthony

Reply via email to