context_processors.py 1.03 KB
Newer Older
1 2 3
"""
Django Template Context Processor for CMS Online Contextual Help
"""
4 5
import ConfigParser
from django.conf import settings
6

7
from util.help_context_processor import common_doc_url
8 9 10


# Open and parse the configuration file when the module is initialized
11 12 13
CONFIG_FILE = open(settings.REPO_ROOT / "docs" / "cms_config.ini")
CONFIG = ConfigParser.ConfigParser()
CONFIG.readfp(CONFIG_FILE)
14 15


16
def doc_url(request=None):  # pylint: disable=unused-argument
17
    """
18
    This function is added in the list of TEMPLATES 'context_processors' OPTION, which is a django setting for
19 20 21 22 23 24 25 26 27
    a tuple of callables that take a request object as their argument and return a dictionary of items
    to be merged into the RequestContext.

    This function returns a dict with get_online_help_info, making it directly available to all mako templates.

    Args:
        request: Currently not used, but is passed by django to context processors.
            May be used in the future for determining the language of choice.
    """
28
    return common_doc_url(request, CONFIG)