[mod_python] session object error

Graham Dumpleton grahamd at dscpl.com.au
Wed Aug 30 00:13:13 EDT 2006

David Bear wrote ..
> I am using modpython 3.1.3 (suse packaged) and am attempting to follow
> the example  at
> http://modpython.org/live/current/doc-html/pyapi-sess-example.html
> However, I get an error on code like this 
> session['hits'] += 1
> saying that the object does not support assignment. Rats. Does my
> modpython not have a good session object? 

Exactly what type of Python exception is being raised?

The Session object derives from 'dict' and so anything that you can do on
a 'dict' instance should still work. The only thing I can think of that could go
awry is that if 'hits' is not in the session object dictionary to begin with.
But then that would result in a KeyError.

>>> a = dict()
>>> a['hits'] += 1
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: 'hits'


More information about the Mod_python mailing list