I'm using an ajax call to default.py controller. The default.py sets a
session variable. Paraphrased, it looks like this:
# model
if not session.myvars:
session.myvars = dict(
somevar=dict(),
othervar=dict(),
...
)
# view
<script>
...
ajax("{{= URL('default', 'setvar', args=[...])}}",[],":eval");
...
</script>
# default.py
if False:
session = current.session # to make Eclipse happy
def setvar():
...
del session.myvars['somevar']
...
return ''
In other controllers, the session.myvars['somevar'] is given a useful value.
Here's the really strange thing. If the ajax script is triggered, the
session.myvars['someval'] dict gets deleted as desired. However, only
temporarily! When another controller later on uses session.myvars, the old
session.myvars['somevar'] is still in existence.
If I reproduce this by putting the del session.myvars['somevar'] in one of
my other controllers, the session.myvars['somevar'] gets deleted
permanently, as desired.
This doesn't just happen for deleting session variables. It also happens
for setting session variables inside the default.py controller.
Why is this happening? Is there something special about default.py that I
don't know about? Are you not supposed to manipulate session variables in
there?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.