+ # Since we can't use Apache's DirectoryIndex directive due to a RewriteCond
+ # passing all non-file objects to this script, we implement equivalent
+ # functionality here.
+ if os.environ['REQUEST_URI'][-1] == "/":
+ os.environ['REQUEST_URI'] = os.environ['REQUEST_URI'] + config.default_page
+
+ # Since we use REQUEST_URI to navigate the filesystem we need to unquote it.
+ # In other words, replace things like '%20' with ' ' (a space character).
+ os.environ['REQUEST_URI'] = urllib.parse.unquote(os.environ['REQUEST_URI'])
+
+ # The template engine operates like a micropass compiler with each pass
+ # handling one tag from the template. Extensions to the template engine
+ # should be executed from here and should not have or create
+ # inter-dependencies.