Permalink
Browse files

- A ``mako.directories`` setting is no longer required to use Mako te…

…mplates

  Rationale: Mako template renderers can be specified using an absolute asset
  spec.  An entire application can be written with such asset specs,
  requiring no ordered lookup path.
  • Loading branch information...
1 parent 34859d5 commit d28528c049267fcf7a05eed22be3f4f78db071da @mcdonc mcdonc committed Oct 16, 2011
Showing with 18 additions and 7 deletions.
  1. +8 −0 CHANGES.txt
  2. +1 −4 pyramid/mako_templating.py
  3. +9 −3 pyramid/tests/test_mako_templating.py
View
@@ -1,6 +1,14 @@
Next release
============
+Features
+--------
+
+- Backport from master: a ``mako.directories`` setting is no longer required
+ to use Mako templates. Rationale: Mako template renderers can be specified
+ using an absolute asset spec. An entire application can be written with
+ such asset specs, requiring no ordered lookup path.
+
Bug Fixes
---------
@@ -63,17 +63,14 @@ def renderer_factory(info):
lookup = registry.queryUtility(IMakoLookup)
if lookup is None:
reload_templates = settings.get('reload_templates', False)
- directories = settings.get('mako.directories', None)
+ directories = settings.get('mako.directories', [])
module_directory = settings.get('mako.module_directory', None)
input_encoding = settings.get('mako.input_encoding', 'utf-8')
error_handler = settings.get('mako.error_handler', None)
default_filters = settings.get('mako.default_filters', 'h')
imports = settings.get('mako.imports', None)
strict_undefined = settings.get('mako.strict_undefined', 'false')
preprocessor = settings.get('mako.preprocessor', None)
- if directories is None:
- raise ConfigurationError(
- 'Mako template used without a ``mako.directories`` setting')
if not hasattr(directories, '__iter__'):
directories = filter(None, directories.splitlines())
directories = [ abspath_from_asset_spec(d) for d in directories ]
@@ -20,14 +20,20 @@ def _callFUT(self, info):
return renderer_factory(info)
def test_no_directories(self):
- from pyramid.exceptions import ConfigurationError
+ from pyramid.mako_templating import IMakoLookup
info = DummyRendererInfo({
- 'name':'helloworld.mak',
+ 'name':'pyramid.tests:fixtures/helloworld.mak',
'package':None,
'registry':self.config.registry,
'settings':{},
})
- self.assertRaises(ConfigurationError, self._callFUT, info)
+ renderer = self._callFUT(info)
+ lookup = self.config.registry.getUtility(IMakoLookup)
+ self.assertEqual(lookup.directories, [])
+ self.assertEqual(lookup.filesystem_checks, False)
+ self.assertEqual(renderer.path,
+ 'pyramid.tests:fixtures/helloworld.mak')
+ self.assertEqual(renderer.lookup, lookup)
def test_no_lookup(self):
from pyramid.mako_templating import IMakoLookup

0 comments on commit d28528c

Please sign in to comment.