Hi everyone,
I'm having some trouble updating session data.

I have a controller/view that allows to perform a query that returns a
bunch of db ids. As I will be using these ids and I used a complex query to
retrieve them I store them in the session,  with the statement below.
Thus another controller will be able to randomly pick one of these ids in
order to use it.

def list_problems_by_training():
    training_id = request.args(0,cast=int,default=1)
    ...
    rows = db(query).select(db.probdata.problem,limitby=(start,stop))

    if session.training_id is None:
        session.training_id = 0
        session.user_training_probs = []
        session.configuration_counter = 0 #REMOVE: for debugging purposes
only

    session.training_id = training_id
    session.user_training_probs = list(set([r.problem  for r in
rows]))#remove duplicates
    session.configuration_counter += 1 #REMOVE: for debugging purposes only
    return locals()

It works fine the 1st time. But once the values are set in the session
object, when I go the the same controller/view to update the list, I'm no
longer able to change it.
It's weird because the view shows the new query results correctly, but the
session data never gets updated. But neither 'training_id' nor
'user_training_probs' are updated correctly. The curious thing is that I
set a counter variable for debugging purposes 'configuration_counter' and
it's updated correctly.

Is the problem related with data types? I deliberately avoided using user
classes (as stated in the manual
http://web2py.com/books/default/chapter/29/04/the-core#Don-t-store-user-defined-classes-in-session
) and used a regular list instead (which is a built-in datatype).

Am I doing something wrong? Is it ok to store query results in the session
or should I cache the result instead?
Thanks in advance.
Regards, Jon.

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to