summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Uiterwijk <puiterwijk@redhat.com>2015-02-03 16:37:47 +0100
committerPatrick Uiterwijk <puiterwijk@redhat.com>2015-02-06 14:41:15 +0100
commitcd6572b7e45b841f25ab505f2ee38b23959be0ad (patch)
treed15445105914fd943aaff89f7ba23beb1533800d
parent125690467138fae6b6186b52d83f06c7aff51c20 (diff)
downloadipsilon-cd6572b7e45b841f25ab505f2ee38b23959be0ad.tar.gz
ipsilon-cd6572b7e45b841f25ab505f2ee38b23959be0ad.tar.xz
ipsilon-cd6572b7e45b841f25ab505f2ee38b23959be0ad.zip
Fall back to default templates dir if it does not exist in template_dir
This would enable people to only override the templates they care about overriding, like master.html, while still retaining the rest. Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
-rwxr-xr-xipsilon/ipsilon18
1 files changed, 13 insertions, 5 deletions
diff --git a/ipsilon/ipsilon b/ipsilon/ipsilon
index 094a09d..46951a5 100755
--- a/ipsilon/ipsilon
+++ b/ipsilon/ipsilon
@@ -26,7 +26,7 @@ import cherrypy
from ipsilon.util.data import AdminStore
from ipsilon.util import page
from ipsilon.root import Root
-from jinja2 import Environment, FileSystemLoader
+from jinja2 import Environment, FileSystemLoader, ChoiceLoader
import ipsilon.util.sessions
@@ -62,12 +62,20 @@ admin_config = datastore.load_config()
for option in admin_config:
cherrypy.config[option] = admin_config[option]
-template_dir = cherrypy.config.get('template_dir', 'templates')
+template_loaders = []
+default_template_dir = 'templates'
+template_dir = cherrypy.config.get('template_dir', default_template_dir)
if template_dir.startswith('/'):
- templates = template_dir
+ template_loaders.append(FileSystemLoader(template_dir))
else:
- templates = os.path.join(cherrypy.config['base.dir'], template_dir)
-template_env = Environment(loader=FileSystemLoader(templates))
+ template_loaders.append(FileSystemLoader(
+ os.path.join(cherrypy.config['base.dir'],
+ template_dir)))
+# Fall-back to the default templates
+template_loaders.append(FileSystemLoader(
+ os.path.join(cherrypy.config['base.dir'],
+ default_template_dir)))
+template_env = Environment(loader=ChoiceLoader(template_loaders))
if __name__ == "__main__":
conf = {'/': {'tools.staticdir.root': os.getcwd()},