New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when renderer is not supported, report back what is missing #81

alfredodeza opened this Issue Sep 8, 2016 · 0 comments


None yet
1 participant
Copy link

alfredodeza commented Sep 8, 2016

Had some issues trying to use jinja2 as renderer but was getting the following traceback:

File ".../pecan/", line 421, in render
    return renderer.render(template, namespace)
AttributeError: 'NoneType' object has no attribute 'render'

This was because jinja2 is not the right name for the renderer.

The following change in would report this with more useful information:

diff --git a/pecan/ b/pecan/
index f02b3a3..3f7f211 100644
--- a/pecan/
+++ b/pecan/
@@ -412,6 +412,8 @@ class PecanBase(object):
+            if renderer is None:
+                raise RuntimeError('template support for %s was not found' % renderer_name)
             renderer = self.renderers.get(

The test case demonstrates the more informative error:

diff --git a/pecan/tests/ b/pecan/tests/
index 435e8b5..2180d47 100644
--- a/pecan/tests/
+++ b/pecan/tests/
@@ -1898,6 +1898,27 @@ class TestEngines(PecanTestCase):
         assert error_msg is not None

+    def test_renderer_not_found(self):
+        class RootController(object):
+            @expose('mako3:mako.html')
+            def index(self, name='Jonathan'):
+                return dict(name=name)
+            @expose('mako3:mako_bad.html')
+            def badtemplate(self):
+                return dict()
+        app = TestApp(
+            Pecan(RootController(), template_path=self.template_path)
+        )
+        try:
+            r = app.get('/')
+        except Exception as e:
+            expected = e
+        assert str(expected) == "template support for mako3 was not found"
     def test_json(self):
             from simplejson import loads

There are also other things in that block that could be used for the error reporting, like the path. It is not uncommon to tell pecan to look at a certain path where a given template doesn't exist, but nothing (currently) points to where that may be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment