In web2py session is not a dict it is a gluon.storage.Storage. It acts
as a dict except that keys can accessed as attributes and if a key
does not exist returns None.

>>> session['key']
Exception
>>> session.key
None
>>> 'key' in session
False


On Feb 3, 9:46 pm, jeantoe <jean...@gmail.com> wrote:
> i see this example in web2py_manual_cut.pdf
>
> code:
> def index():
>
>       session.counter = (session.counter or 0) + 1
>
>       return dict(message="Hello from MyApp", counter=session.counter)
>
> i try it in ipython and get a error
>
> In [13]: session.test  = (session.test or 0) + 1
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call
> last)
>
> /home/jean/Python/web2py/<ipython console> in <module>()
>
> AttributeError: class session has no attribute 'test'
>
> try another
>
> In [14]: session.test = None
>
> In [15]: session.test  = (session.test or 0) + 1
>
> i think web2py automatism a key None if the key not exist?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to