You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
488 B

  1. from django.core.signing import JSONSerializer as BaseJSONSerializer
  2. try:
  3. from django.utils.six.moves import cPickle as pickle
  4. except ImportError:
  5. import pickle
  6. class PickleSerializer(object):
  7. """
  8. Simple wrapper around pickle to be used in signing.dumps and
  9. signing.loads.
  10. """
  11. def dumps(self, obj):
  12. return pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)
  13. def loads(self, data):
  14. return pickle.loads(data)
  15. JSONSerializer = BaseJSONSerializer