Configuration registry

Registry store configurations by the way of its interface.

Default global registry is available at rstview.registry.rstview_registry and is global for the whole project and apps, you don’t need to fill it again for a same Django instance.

A configuration is a dictionnary of parameters for reStructuredText parser:

{
    'default': {
        'initial_header_level': 1,
        'language_code': "en",
    },
}

Configuration name is used to retrieve parameters from the registry interface.

See Docutils Configuration for a full references of available parser parameters.

class rstview.registry.RstConfigSite(*args, **kwargs)[source]

Rstview configurations registry

Keyword Arguments:
 
  • initial (dict) – Optional initial dictionnary of configuration. Default
  • an empty dict. (to) –
get_names()[source]

Return registred configuration names.

Returns:List of registred names, sorted with default sorted() behavior.
Return type:list
get_parameters(name)[source]

Get parameters from given configuration name.

Parameters:name (string) – Configuration name.
Returns:Configuration parameters.
Return type:string or tuple
get_registry()[source]

Return current registry

Returns:Currrent registry.
Return type:dict
has_name(name)[source]

Find if given name is a registred configuration name.

Returns:True if name exists in current registry, else False.
Return type:bool
register(name, value)[source]

Register a configuration for given name.

Parameters:
  • name (string) – Configuration name.
  • value (string or tuple) – Configuration parameters to define.
Raises:
  • RstviewConfigAlreadyRegistered if name is allready registered in
  • configurations.
reset()[source]

Reset registry to an empty Dict.

unregister(name)[source]

Unregister a configuration from its name.

Parameters:name (string) – Url name.
Raises:RstviewConfigNotRegistered if given url name is not registred yet.
update(configs)[source]

Update many configuration.

This works like the Dict.update({..}) method.

Parameters:configs (dict) – A dict of configurations.
rstview.registry.rstview_registry = <rstview.registry.RstConfigSite object>

Default rstview configurations registry for a Django instance.