Configurations are registred through files (called configuration file) that are loaded as Python modules where some code can register needed configurations.
Discovering will find these configuration files through project and its enabled applications.
Usually you will want to use automatic discovering with the
function, so you just have to initiate it once from your project (like in your
urls.py) to load every configuration files.
In some uncommon cases you may need to do discovering yourself from your code,
discover function to do so.
Automatic discovering for available configurations
Before looking at configurations files, registry start from
settings.RSTVIEW_PARSER_FILTER_SETTINGSitems if setted, else an empty Dict.
Then it try to load possible root configurations file defined in
settings.RSTVIEW_PARSER_ROOT_CONFIGS(as a Python path).
And finally load each configurations files finded in
from rstview.discover import autodiscover autodiscover()
This is something you want to be executed early in your project, usually the
urls.pyof your project is the best choice.
Keyword Arguments: filename (string) – Module filename to search for. Default to
rstview_configs, so it will search for a
rstview_configs.pyfile at root of every enabled module from
Returns: List of successfully loaded Python paths. Return type: list
Try to discover and load a configuration file from given Python path.
Supposing you made a configuration file at
1 2 3
from rstview.discover import discover discover("myproject.myapp", "rstview_configs")
Parameters: module_path (string) – Python path to scan for
Keyword Arguments: filename (string) – Optional module filename to search for, default to
Exception– Raise any occuring exception from loaded Python path.
Returns: Python path (
module.filename) for discovered configuration module. If
filenamedoes not exists in module, return
Return type: string or None