If instances are pickable then you should be okay.  Have you tried saving 
them to the session and seeing what happens?  Note that sometimes you can 
pickle things okay but the unpickle throws the error.

Failing that have a look at the recipe near the bottom of this thread...
http://bytes.com/topic/python/answers/552476-why-cant-you-pickle-instancemethods

BTW, that's no good for web2py classes, which don't pickle because they are 
db connections.


On Friday, March 30, 2012 12:21:37 PM UTC+13, Web2py Newbie wrote:
>
> I have an existing application that I am trying to get running as AJAX 
> with web2py (locally, but eventually to run on GAE).  The application makes 
> use of class instances to store much of the data which would be used for 
> user sessions.  I understand that session can't be used to store class 
> instances but for the time being I want to keep the instances for each 
> session (about 200K of data).   Sooner or later I guess I will need to save 
> this data in the data store, but at the moment I'm trying to get a 
> prototype up and running and reworking the code to get the data into/out of 
> a database is more pain than I can face atm.   The instances are pickleable 
> (well, cPickle doesn't complain)
>
> My options seem to be:
> * cache in ram using the session id as a key and
> * dumping the instance to a string, saving the string to session  (on GAE 
> will this be the same as cache.ram?)
>
> Are there other approaches?  What's the best way to go about this?
>
> Also, in the next update of the documentation, this would be a useful 
> detail to include on the session related sections.    
>
> Thanks in advance
>
> Brendan 
>

Reply via email to