A heirarchy of user classes (Rpg, Character, Combat, Enemy, etc.). I did 
figure out a way to get around this - I added jsonpickle to site-packages, 
and then I'm storing the encoded object in a json field in the table.

But yes, that was the error I got with the binary version of the pickle, 
stored in a blob field. With the text version, I got an "unrecognized 
token" error, which seemed to be happening because the field wasn't being 
escaped correctly.

On Saturday, March 14, 2015 at 9:24:18 AM UTC-7, Massimo Di Pierro wrote:
>
> In general you can pickle an object and store in blob or text field in 
> web2py. Your problem is not this but this:
>
>
> http://stackoverflow.com/questions/1412787/picklingerror-cant-pickle-class-decimal-decimal-its-not-the-same-object
>
> The problem is with one (or more) of the objects your pickling. Which 
> classes are you pickling?
>
> On Friday, 13 March 2015 16:30:39 UTC-5, Gray Kanarek wrote:
>>
>> I'm working on a website for a game, the engine of which involves a 
>> heirarchy of custom classes. I need to find some way to store the gamestate 
>> between sessions, so that logged-in users can pick up a game from one of 
>> their associated characters from where they last saved.
>>
>> My original idea was to pickle the game engine and store it in a text or 
>> blob field in my db.characters table, so that each character would have 
>> their associated gamestate stored in the same table. However, when trying a 
>> text field, the pickled object wasn't escaped correctly so it threw an 
>> SQLite error; using a binary pickle stored in a blob field, it threw a 
>> "<class> is not the same as object" PicklingError.
>>
>> Are there ways to get around either of these errors? Or is there some 
>> other way I should be storing the game sessions? There are enough variables 
>> and nested objects that storing them in individual fields of a table would 
>> be a real pain; I thought about trying to integrate ZODB, but I have no 
>> idea if web2py plays nice with object databases.
>>
>> Any suggestions? Thanks!
>>
>

-- 
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.

Reply via email to