MPT Consul Parser

class django_docker_helpers.config.backends.mpt_consul_parser.MPTConsulParser(scope=None, host='', port=8500, scheme='http', verify=True, cert=None, path_separator='.', consul_path_separator='/', object_deserialize_prefix='::YAML::\\n', object_deserialize=<function default_yaml_object_deserialize>)[source]

Materialized Path Tree Consul Parser.

Compared to, e.g. ConsulParser it does not load a whole config file from a single key, but reads every config option from a corresponding variable path.


parser = MPTConsulParser(host=CONSUL_HOST, port=CONSUL_PORT, path_separator='.')

If you want to store your config with separated key paths take mp_serialize_dict() helper to materialize your dict.

  • scope (Optional[str]) – a global namespace-like variable prefix

  • host (str) – consul host, default is ''

  • port (int) – consul port, default is 8500

  • scheme (str) – consul scheme, default is 'http'

  • verify (bool) – verify certs, default is True

  • cert – path to certificate bundle

  • path_separator (str) – specifies which character separates nested variables, default is '.'

  • consul_path_separator (str) – specifies which character separates nested variables in consul kv storage, default is '/'

  • object_deserialize_prefix (str) – if object has a specified prefix, it’s deserialized with object_deserialize

  • object_deserialize (Optional[Callable]) – deserializer for complex variables

get(variable_path, default=None, coerce_type=None, coercer=None, **kwargs)[source]
  • variable_path (str) – a delimiter-separated path to a nested value

  • default (Optional[Any]) – default value if there’s no object by specified path

  • coerce_type (Optional[Type]) – cast a type of a value to a specified one

  • coercer (Optional[Callable]) – perform a type casting with specified callback

  • kwargs – additional arguments inherited parser may need


value or default


If your backend needs a client, inherit this method and use client() shortcut.


an instance of backend-specific client