@classmethod
def register_class_to_dict(cls, clazz, converter, serpent_too=True):
    'Registers a custom function that returns a dict representation of objects of the given class.\n        The function is called with a single parameter; the object to be converted to a dict.'
    cls.__custom_class_to_dict_registry[clazz] = converter
    if serpent_too:
        try:

            def serpent_converter(obj, serializer, stream, level):
                d = converter(obj)
                serializer.ser_builtins_dict(d, stream, level)
            serpent.register_class(clazz, serpent_converter)
        except errors.ProtocolError:
            pass
Registers a custom function that returns a dict representation of objects of the given class.
The function is called with a single parameter; the object to be converted to a dict.
@classmethod
def register_class_to_dict(cls, clazz, converter, serpent_too=True):
    'Registers a custom function that returns a dict representation of objects of the given class.\n        The function is called with a single parameter; the object to be converted to a dict.'
    cls.__custom_class_to_dict_registry[clazz] = converter
    if serpent_too:
        try:

            def serpent_converter(obj, serializer, stream, level):
                d = converter(obj)
                serializer.ser_builtins_dict(d, stream, level)
            serpent.register_class(clazz, serpent_converter)
        except errors.ProtocolError:
            pass