ns
kombu.serialization
===================
Serialization utilities.
Centralized support for encoding/decoding of data structures.
Contains json, pickle, msgpack, and yaml serializers.
Optionally installs support for YAML if the PyYAML package
is installed.
Optionally installs support for msgpack if the msgpack-python
package is installed.
-
exception kombu.serialization.SerializerNotInstalled
Support for the requested serialization type is not installed
-
kombu.serialization.encode(self, data, serializer=None)
-
decode(data, content_type, content_encoding):
Deserialize a data stream as serialized using encode
based on content_type.
Parameters: |
- data – The message data to deserialize.
- content_type – The content-type of the data.
(e.g., application/json).
- content_encoding – The content-encoding of the data.
(e.g., utf-8, binary, or us-ascii).
|
Returns: | The unserialized data.
|
-
kombu.serialization.decode(self, data, content_type, content_encoding, accept=None, force=False)
-
register(name, encoder, decoder, content_type,
-
content_encoding='utf-8'):
-
Register a new encoder/decoder.
Parameters: |
- name – A convenience name for the serialization method.
- encoder – A method that will be passed a python data structure
and should return a string representing the serialized data.
If None, then only a decoder will be registered. Encoding
will not be possible.
- decoder – A method that will be passed a string representing
serialized data and should return a python data structure.
If None, then only an encoder will be registered.
Decoding will not be possible.
- content_type – The mime-type describing the serialized
structure.
- content_encoding – The content encoding (character set) that
the decoder method will be returning. Will usually be
utf-8`, us-ascii, or binary.
|
-
kombu.serialization.raw_encode(data)
Special case serializer.
-
kombu.serialization.register(self, name, encoder, decoder, content_type, content_encoding='utf-8')
-
unregister(name):
-
Unregister registered encoder/decoder.
Parameters: | name – Registered serialization method name. |
-
kombu.serialization.registry = <kombu.serialization.SerializerRegistry object at 0x3815990>
-
kombu.serialization.encode(data, serializer=default_serializer)
Serialize a data structure into a string suitable for sending
as an AMQP message body.
Parameters: |
- data – The message data to send. Can be a list,
dictionary or a string.
- serializer –
An optional string representing
the serialization method you want the data marshalled
into. (For example, json, raw, or pickle).
If None (default), then json will be used, unless
data is a str or unicode object. In this
latter case, no serialization occurs as it would be
unnecessary.
Note that if serializer is specified, then that
serialization method will be used even if a str
or unicode object is passed in.
|
Returns: | A three-item tuple containing the content type
(e.g., application/json), content encoding, (e.g.,
utf-8) and a string containing the serialized
data.
|
Raises SerializerNotInstalled: |
| If the serialization method
requested is not available.
|