Storing Nested dictionary Session values

25 views
Skip to first unread message

Pradeep Kumar Mantha

unread,
Apr 26, 2013, 9:39:56 PM4/26/13
to gae-se...@googlegroups.com
Hi,
Can we have nested dictionaries stored as session values for a particular key?


Consider there are two pages, A and B.

I tried storing a nested dictionary as a session value in A's post method, I can the session values in python logs , but  somehow those values are missed , when received in get method of B page handler.


For example

INFO 2013-04-27 00:03:54,962 genergy.py:715] SID=1367625833_21d8679ec0f7dab4c125da6e4ea2fa3b {'after': {}, 'after_dcs': 1, 'current_dcs': 1, 'current': {1: {'dc_state': u'', 'redundancy': u'N', 'users_servers': u'option1', 'dc_type': 'Closet', 'nbr_servers': 1.0, 'nbr_users': 25.0, 'user_host': u'300', 'server_user_ratio': 1.0, 'application': 'Email', 'dc_country': u'', 'carbon': u'343'}}, 'model': 'current', 'first': True}
INFO 2013-04-27 00:03:54,963 recording.py:673] Saved; key: appstats:034900, part: 21 bytes, full: 1619 bytes, overhead: 0.000 + 0.001; link: http://localhost:8082/_ah/stats/details?time=1367021034959

INFO 2013-04-27 00:03:54,970 dev_appserver.py:3104] "POST / HTTP/1.1" 302 -
INFO 2013-04-27 00:03:54,983 genergy.py:478] SID=1367625833_21d8679ec0f7dab4c125da6e4ea2fa3b {'after': {}, 'after_dcs': 1, 'current_dcs': 1, 'current': {}, 'model': 'current', 'first': True}
ERROR 2013-04-27 00:03:54,985 webapp2.py:1552] 1

Could you please check , whether nested dictionary values can be stored in sessions or not.

thanks
pradeep

David Underhill

unread,
Apr 26, 2013, 11:02:08 PM4/26/13
to gae-se...@googlegroups.com
Nested dictionaries shouldn't be a problem.  Anything which can be pickled can be stored in a session.


--
You received this message because you are subscribed to the Google Groups "gae-sessions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gae-sessions...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pradeep Kumar Mantha

unread,
Apr 26, 2013, 11:44:48 PM4/26/13
to gae-se...@googlegroups.com
Hi,

I tried to store the session values as below

session['1']={}
session['1']['2']={}
session['1']['2']['key'] = val  in post method of a Page Handler.

Tried to retrieve the same in get method of another handler. I do not see that key. Not sure, what went wrong. Please find the logs in previous mail. 


Please let me know if there is anyway I can debug.

thanks
pradeep

Pradeep Kumar Mantha

unread,
May 2, 2013, 12:22:01 PM5/2/13
to gae-se...@googlegroups.com
I solved this problem, by pickling the nested dictionary before sending to another page handler's get request.

David Underhill

unread,
May 2, 2013, 7:57:01 PM5/2/13
to gae-se...@googlegroups.com
Awesome, thanks for sharing your workaround Pradeep!
Reply all
Reply to author
Forward
0 new messages