From 8b5cad8687c2249ac3d2ef019a2ced80347aa107 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 25 Jan 2012 18:09:49 -0800 Subject: [PATCH] Move toggle for template caching into its own .ini flag. --- r2/example.ini | 6 ++++-- r2/r2/config/environment.py | 2 +- r2/r2/lib/app_globals.py | 1 + r2/r2/lib/wrapped.pyx | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/r2/example.ini b/r2/example.ini index 53fb7dc507..79c05f349b 100755 --- a/r2/example.ini +++ b/r2/example.ini @@ -8,8 +8,10 @@ # -- debug and configuation flags -- # global debug flag -- displays pylons stacktrace rather than 500 page on error when true debug = true -# enables/disables template caching and whitespace removal (for development) -template_debug = true +# enables/disables whitespace removal (for development) +template_debug = false +# enables/disables compiled template caching and template file mtime checking +reload_templates = true # use uncompressed static files (out of /static/js and /static/css) # rather than compressed files out of /static (for development if true) uncompressedJS = true diff --git a/r2/r2/config/environment.py b/r2/r2/config/environment.py index f22f8461d6..9870233052 100644 --- a/r2/r2/config/environment.py +++ b/r2/r2/config/environment.py @@ -68,7 +68,7 @@ def load_environment(global_conf={}, app_conf={}, setup_globals=True): #tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link, s=webhelpers.simple_format) tmpl_options = config['buffet.template_options'] - tmpl_options['mako.filesystem_checks'] = g.debug + tmpl_options['mako.filesystem_checks'] = getattr(g, 'reload_templates', False) tmpl_options['mako.default_filters'] = ["mako_websafe"] tmpl_options['mako.imports'] = \ ["from r2.lib.filters import websafe, unsafe, mako_websafe", diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index 5153f90fa6..8d12fcaf17 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -79,6 +79,7 @@ class Globals(object): 'log_start', 'sqlprinting', 'template_debug', + 'reload_templates', 'uncompressedJS', 'enable_doquery', 'use_query_cache', diff --git a/r2/r2/lib/wrapped.pyx b/r2/r2/lib/wrapped.pyx index 6bbb0aec18..efd438c0ca 100644 --- a/r2/r2/lib/wrapped.pyx +++ b/r2/r2/lib/wrapped.pyx @@ -175,11 +175,11 @@ class Templated(object): from r2.config.templates import tpm from pylons import g - debug = g.template_debug + use_cache = not g.reload_templates template = None try: template = tpm.get(self.render_class, - style, cache = not debug) + style, cache = use_cache) except AttributeError: self._notfound(style) return template