2017-01-07 19:11:46 +08:00
|
|
|
import pickle
|
2015-01-28 20:35:27 +08:00
|
|
|
|
2017-01-07 19:11:46 +08:00
|
|
|
from django.core.signing import JSONSerializer as BaseJSONSerializer
|
2013-08-22 08:12:19 +08:00
|
|
|
|
|
|
|
|
2017-01-19 15:39:46 +08:00
|
|
|
class PickleSerializer:
|
2013-08-22 08:12:19 +08:00
|
|
|
"""
|
|
|
|
Simple wrapper around pickle to be used in signing.dumps and
|
|
|
|
signing.loads.
|
|
|
|
"""
|
2018-07-07 05:55:46 +08:00
|
|
|
protocol = pickle.HIGHEST_PROTOCOL
|
|
|
|
|
2013-08-22 08:12:19 +08:00
|
|
|
def dumps(self, obj):
|
2018-07-07 05:55:46 +08:00
|
|
|
return pickle.dumps(obj, self.protocol)
|
2013-08-22 08:12:19 +08:00
|
|
|
|
|
|
|
def loads(self, data):
|
|
|
|
return pickle.loads(data)
|
|
|
|
|
|
|
|
|
|
|
|
JSONSerializer = BaseJSONSerializer
|