]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make it possible to override template_path at the handler level
authorBen Darnell <bdarnell@beaker.local>
Thu, 20 May 2010 20:50:03 +0000 (13:50 -0700)
committerBen Darnell <bdarnell@beaker.local>
Thu, 20 May 2010 20:50:03 +0000 (13:50 -0700)
tornado/web.py

index e51948a2217d0042f58e6a5b6c0e56c08fc3b438..ea48044f1b378d8e8928f63795efcc94c929a11e 100644 (file)
@@ -419,7 +419,7 @@ class RequestHandler(object):
         as a response, use render() above.
         """
         # If no template_path is specified, use the path of the calling file
-        template_path = self.application.settings.get("template_path")
+        template_path = self.get_template_path()
         if not template_path:
             frame = sys._getframe(0)
             web_file = frame.f_code.co_filename
@@ -606,6 +606,14 @@ class RequestHandler(object):
         self.require_setting("login_url", "@tornado.web.authenticated")
         return self.application.settings["login_url"]
 
+    def get_template_path(self):
+        """Override to customize template path for each handler.
+
+        By default, we use the 'template_path' application setting.
+        Return None to load templates relative to the calling file.
+        """
+        return self.application.settings.get("template_path")
+
     @property
     def xsrf_token(self):
         """The XSRF-prevention token for the current user/session.