import ConfigParser
from django.conf import settings


def doc_url(request):
    config_file = open(settings.REPO_ROOT / "docs" / "config.ini")
    config = ConfigParser.ConfigParser()
    config.readfp(config_file)

    # in the future, we will detect the locale; for now, we will
    # hardcode en_us, since we only have English documentation
    locale = "en_us"

    def get_doc_url(token):
        try:
            return config.get(locale, token)
        except ConfigParser.NoOptionError:
            return config.get(locale, "default")

    return {"doc_url": get_doc_url}

@@ -51,35 +51,8 @@
 gs%0A%0A
-%0Adef doc_url(request):%0A    
 conf
@@ -110,20 +110,16 @@
 g.ini%22)%0A
-    
 config =
@@ -147,20 +147,16 @@
 arser()%0A
-    
 config.r
@@ -175,16 +175,39 @@
 _file)%0A%0A
+%0Adef doc_url(request):%0A
     # in

Read from doc url mapping file at load time, rather than once per request