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.

serializers.py 424B

5 years ago
1234567891011121314151617181920
  1. import pickle
  2. from django.core.signing import JSONSerializer as BaseJSONSerializer
  3. class PickleSerializer:
  4. """
  5. Simple wrapper around pickle to be used in signing.dumps and
  6. signing.loads.
  7. """
  8. protocol = pickle.HIGHEST_PROTOCOL
  9. def dumps(self, obj):
  10. return pickle.dumps(obj, self.protocol)
  11. def loads(self, data):
  12. return pickle.loads(data)
  13. JSONSerializer = BaseJSONSerializer