Files
edx-platform/openedx/core/lib/session_serializers.py
Jawayria 4cdf466215 refactor: Removed unused imports
Removed unused imports from openedx/core/{djangolib, lib} and openedx/{tests, features}
2021-04-06 17:24:04 +05:00

30 lines
737 B
Python

"""
Custom session serializer to deal with going from python2 and python3.
"""
import pickle
class PickleSerializer(object):
"""
Set the pickle protocol version explicitly because we don't want
to have session thrashing when we upgrade to newer versions of
python.
Based on the PickleSerializer built into django:
https://github.com/django/django/blob/master/django/contrib/sessions/serializers.py
"""
protocol = 4
def dumps(self, obj):
"""
Return a pickled representation of object.
"""
return pickle.dumps(obj, self.protocol)
def loads(self, data):
"""
Return a python object from pickled data.
"""
return pickle.loads(data)