From: Ben Darnell Date: Thu, 20 May 2010 20:50:03 +0000 (-0700) Subject: Make it possible to override template_path at the handler level X-Git-Tag: v1.0.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9a9ccc38841fcb9f8486e0d2854d570c34fe4c8;p=thirdparty%2Ftornado.git Make it possible to override template_path at the handler level --- 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.