James Gardner: Home > Work > Code > ConversionKit > 0.3.0 > Appendix D: API Documentation

ConversionKit v0.3.0 documentation

Appendix D: API Documentation

The conversionkit Module

Conversion Toolkit

See the docs/source/manual.rst for an explanation of this module.

class conversionkit.Conversion(value)

When writing converters for this conversion object you should ensure that converters designed to work with single values set the .result attribute directly whereas converters which operate on nested data structures set the .children attribute and leave this object to calculate the result from the child conversions.

successful
Can return True or False. Raises a ConversionKitError exception if no conversion has been performed yet.
class conversionkit.Missing
This class is used in a toDictionary() conversion when a field is missing. In order to make the handling of errors due to missing fields consistent with the behaviour of other errors, including empty value errors, a child conversion is set up for the missing field but because no value was present it isn’t possible to set a .value attribute on the conversion so this class is used instead.
conversionkit.toDictionary(converters, missing_defaults=None, empty_defaults=None, missing_errors=None, empty_errors=None, missing_or_empty_errors=None, missing_or_empty_defaults=None, filter_extra_fields=True, allow_extra_fields=True, raise_on_extra_fields=True, use_many_message_after_failures=3, msg_many_invalid_fields='Multiple fields were invalid', msg_some_invalid_fields='The %(fields)s fields were invalid', msg_single_invalid_field='The %(field)s field is invalid')
This is a converter which handles pre-converters and post converters as well as a dictionary of converters. Rather than using this class it is recommended you use make_dictionary() together with the chain() converter to chain any pre-handlers, dictionary converter and post-handlers.
James Gardner: Home > Work > Code > ConversionKit > 0.3.0 > Appendix D: API Documentation