On Wed, Mar 13, 2013 at 1:08 AM, Vixus <[email protected]> wrote:
> I have defined a Search class in models/search.py and I store this in
> session:
>
> if session.search == None:
> session.search = Search()
>
> But I was wondering why nothing that was being set in the class was being
> carried throughout the session, and when I checked it turns out that this
> session variable is being reset every time a page is loaded. I tried
> reproducing the session.counter example (in addition to session.search) and
> the counter does not increase because it is being reset every time.
>
> My sessions are being saved in the database.
>
> Search() looks like this: http://sprunge.us/VaLN
>
> What could be happening? Is web2py having trouble (un)pickling the session
> data? Is there an issue with storing a class inside session like this?
The unpickling is failling silently with an ImportError:
ImportError: No module named __restricted__
You can put your "Class Search" in modules/search.py for example
and in models do your logic:
import search
if session.search is None:
session.search = search.Search()
Note: I do not feel comfortable pickling instance's like this, I
always avoid it.
Ricardo
--
---
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/groups/opt_out.