From b9a9ccc38841fcb9f8486e0d2854d570c34fe4c8 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Thu, 20 May 2010 13:50:03 -0700 Subject: [PATCH] Make it possible to override template_path at the handler level --- tornado/web.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tornado/web.py b/tornado/web.py index e51948a22..ea48044f1 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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. -- 2.47.2