Re: [web2py] Odd hasattr(session, 'blah'). Don't understand it.

2012-02-09 Thread Bruno Rocha
session is an Storage, Storages always return an attribute, defaults to None. You do not have to always access session objects by keys, you can do it by attribute and it will always return an object, even if the object does not exists. examples my_var = getattr(session, request.controller) Even

[web2py] Odd hasattr(session, 'blah'). Don't understand it.

2012-02-09 Thread Cliff
In an index function I do something like session[request.controller].something = 'foo' This raises a key error exception on the first visit to the controller after restarting the browser. Session can't find the controller name, so I can't add an attribute to it. So I need to initialize the sessi