Priority: Major - P3
Affects Version/s: 2.2
Fix Version/s: 2.2.1
Environment:Windows 7, MongoDB 2.0.3, Python 2.7, pymongo 2.2, Django 1.3, Piston 0.2.3, mango (https://github.com/vpulim/mango) 0.1, 127.0.0.1:8000
I'm using mango.session, witch stores django sessions in mongodb.
Storing sessions works ok.
But when i'm trying to restore session it comes empty.
When debugging into deeps, found that pickle.loads(pickled) - session_data throws exception UnicodeEncodeError:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 3-4: ordinal not in range(256)
Then i tried to eliminate error and added to except clause UnicodeEncodeError (to existing UnicodeDecodeError and AttributeError).
Works like a charm.
Then I tried to reproduce this behavior in IDLE and had no luck. Only see UnicodeDecodeError with same data as I get from db.
Pickled string looked like:
Here truncated code from django.contrib.sessions.backends.base.py SessionBase.load:
IDLE with this code works ok (UnicodeDecodeError supressed) and result dict as expected:
But when this run in django app i see that int _setstate__ as value passed some binary value (see screenshot from eclipse debug variables) witch throws UnicodeEncodeError when trying to convert it to latin-1. And self.__id = value in except block (if I add UnicodeEncodeError to except) works right.
I'm a newbie to python and mongodb, maybe that is my mistake. Thanx.