Jimmy Yuen Ho Wong committed d0d172e

moved template loader to the pythonhk package

  • Participants
  • Parent commits 68fe8a0

Comments (0)

Files changed (2)


 import cherrypy
+import pythonhk
 from pythonhk import api
     def index(self):
-        template ="index.html")
+        template = pythonhk.template_loader.get_template("index.html")
         return template.render()


 from jinja2 import Environment
 from redis.client import Redis
+import pythonhk
 from pythonhk.cp.plugins import *
 from pythonhk.controllers import Root as WebRoot
 from pythonhk.rest_api import api_routes, error_handlers
     def merge(self, config):
         cherrypy.Application.merge(self, config)
-        jinja2_config = dict([(k.replace('jinja2.', ''), v) for k, v in self.config.get('view', {}).iteritems() if k.startswith('jinja2.')])
-        self.template_loader = Environment(**jinja2_config)
         self.cache = Redis(**dict([(k, v) for k, v in self.config.get('redis', {}).iteritems()]))
 def main():
     config = init(args, args.configfiles)
+    jinja2_config = dict([(k.replace('jinja2.', ''), v) for k, v in config.get('view', {}).iteritems() if k.startswith('jinja2.')])
+    pythonhk.template_loader = Environment(**jinja2_config)
     cherrypy.tree.mount(Application(WebRoot(), '', config))