summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-04-26 05:33:35 +0000
committerChris McDonough <chrism@agendaless.com>2010-04-26 05:33:35 +0000
commit8888a57341531bd1e50bd306bdff7a35c25c46da (patch)
treed1e3494ab55077144fe7a7d69eca56f2c6573517
parent05d03298c2e6faedb28786872ea47d5a04ae525f (diff)
downloadpyramid-8888a57341531bd1e50bd306bdff7a35c25c46da.tar.gz
pyramid-8888a57341531bd1e50bd306bdff7a35c25c46da.tar.bz2
pyramid-8888a57341531bd1e50bd306bdff7a35c25c46da.zip
Be kind to KARL: don't assume "debug_templates" will be in the settings dict.
-rw-r--r--repoze/bfg/chameleon_text.py9
-rw-r--r--repoze/bfg/chameleon_zpt.py9
-rw-r--r--repoze/bfg/tests/test_chameleon_text.py10
-rw-r--r--repoze/bfg/tests/test_chameleon_zpt.py10
4 files changed, 34 insertions, 4 deletions
diff --git a/repoze/bfg/chameleon_text.py b/repoze/bfg/chameleon_text.py
index 73457a128..7aca29529 100644
--- a/repoze/bfg/chameleon_text.py
+++ b/repoze/bfg/chameleon_text.py
@@ -50,8 +50,13 @@ class TextTemplateRenderer(object):
@reify # avoid looking up reload_templates before manager pushed
def template(self):
settings = get_settings()
- auto_reload = settings and settings['reload_templates']
- debug = settings and settings['debug_templates']
+ debug = False
+ auto_reload = False
+ if settings:
+ # using .get here is a strategy to be kind to old *tests* rather
+ # than being kind to any existing production system
+ auto_reload = settings.get('reload_templates')
+ debug = settings.get('debug_templates')
reg = get_current_registry()
translate = None
if reg is not None:
diff --git a/repoze/bfg/chameleon_zpt.py b/repoze/bfg/chameleon_zpt.py
index bacb102bb..ba4c9863f 100644
--- a/repoze/bfg/chameleon_zpt.py
+++ b/repoze/bfg/chameleon_zpt.py
@@ -33,8 +33,13 @@ class ZPTTemplateRenderer(object):
@reify # avoid looking up reload_templates before manager pushed
def template(self):
settings = get_settings()
- auto_reload = settings and settings['reload_templates']
- debug = settings and settings['debug_templates']
+ debug = False
+ auto_reload = False
+ if settings:
+ # using .get here is a strategy to be kind to old *tests* rather
+ # than being kind to any existing production system
+ auto_reload = settings.get('reload_templates')
+ debug = settings.get('debug_templates')
reg = get_current_registry()
translate = None
if reg is not None:
diff --git a/repoze/bfg/tests/test_chameleon_text.py b/repoze/bfg/tests/test_chameleon_text.py
index 38bbc060c..cb30f489a 100644
--- a/repoze/bfg/tests/test_chameleon_text.py
+++ b/repoze/bfg/tests/test_chameleon_text.py
@@ -90,6 +90,16 @@ class TextTemplateRendererTests(Base, unittest.TestCase):
template = instance.template
self.assertEqual(template.auto_reload, True)
+ def test_template_with_emptydict(self):
+ from repoze.bfg.interfaces import ISettings
+ self.config.registry.registerUtility({}, ISettings)
+ minimal = self._getTemplatePath('minimal.txt')
+ instance = self._makeOne(minimal)
+ self.failIf('template' in instance.__dict__)
+ template = instance.template
+ self.assertEqual(template.auto_reload, False)
+ self.assertEqual(template.debug, False)
+
def test_call(self):
minimal = self._getTemplatePath('minimal.txt')
instance = self._makeOne(minimal)
diff --git a/repoze/bfg/tests/test_chameleon_zpt.py b/repoze/bfg/tests/test_chameleon_zpt.py
index b24a0430c..4ea5fc281 100644
--- a/repoze/bfg/tests/test_chameleon_zpt.py
+++ b/repoze/bfg/tests/test_chameleon_zpt.py
@@ -91,6 +91,16 @@ class ZPTTemplateRendererTests(Base, unittest.TestCase):
template = instance.template
self.assertEqual(template.auto_reload, True)
+ def test_template_with_emptydict(self):
+ from repoze.bfg.interfaces import ISettings
+ self.config.registry.registerUtility({}, ISettings)
+ minimal = self._getTemplatePath('minimal.pt')
+ instance = self._makeOne(minimal)
+ self.failIf('template' in instance.__dict__)
+ template = instance.template
+ self.assertEqual(template.auto_reload, False)
+ self.assertEqual(template.debug, False)
+
def test_call_with_nondict_value(self):
minimal = self._getTemplatePath('minimal.pt')
instance = self._makeOne(minimal)