MCPcopy
hub / github.com/celery/celery / serialize

Method serialize

celery/security/serialization.py:31–46  ·  view source on GitHub ↗

Serialize data structure into string.

(self, data)

Source from the content-addressed store, hash-verified

29 self._serializer = serializer
30
31 def serialize(self, data):
32 """Serialize data structure into string."""
33 assert self._key is not None
34 assert self._cert is not None
35 with reraise_errors('Unable to serialize: {0!r}', (Exception,)):
36 content_type, content_encoding, body = dumps(
37 data, serializer=self._serializer)
38
39 # What we sign is the serialized body, not the body itself.
40 # this way the receiver doesn't have to decode the contents
41 # to verify the signature (and thus avoiding potential flaws
42 # in the decoding step).
43 body = ensure_bytes(body)
44 return self._pack(body, content_type, content_encoding,
45 signature=self._key.sign(body, self._digest),
46 signer=self._cert.get_id())
47
48 def deserialize(self, data):
49 """Deserialize data structure from string."""

Callers 6

test_serializeMethod · 0.80
test_unknown_sourceMethod · 0.80
test_self_sendMethod · 0.80
test_separate_endsMethod · 0.80
test_lots_of_signMethod · 0.80

Calls 4

_packMethod · 0.95
reraise_errorsFunction · 0.85
signMethod · 0.80
get_idMethod · 0.80

Tested by 6

test_serializeMethod · 0.64
test_unknown_sourceMethod · 0.64
test_self_sendMethod · 0.64
test_separate_endsMethod · 0.64
test_lots_of_signMethod · 0.64