summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt3
-rw-r--r--docs/narr/environment.rst48
-rw-r--r--pyramid/mako_templating.py6
3 files changed, 57 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index f1e55ffce..e8595d6fc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,9 @@ Next release
Features
--------
+- Added Mako TemplateLookup settings for ``mako.error_handler``,
+ ``mako.default_filters``, and ``mako.imports``.
+
- Normalized all paster templates: each now uses the name ``main`` to
represent the function that returns a WSGI application, each now uses
WebError, each now has roughly the same shape of development.ini style.
diff --git a/docs/narr/environment.rst b/docs/narr/environment.rst
index 2aa4064cd..6df0998d6 100644
--- a/docs/narr/environment.rst
+++ b/docs/narr/environment.rst
@@ -201,6 +201,54 @@ should be changed accordingly.
| |
+-----------------------------+
+Mako Error Handler
+++++++++++++++++++
+
+Python callable which is called whenever Mako compile or runtime exceptions
+occur. The callable is passed the current context as well as the exception. If
+the callable returns True, the exception is considered to be handled, else it
+is re-raised after the function completes. Is used to provide custom
+error-rendering functions.
+
++-----------------------------+
+| Config File Setting Name |
++=============================+
+| ``mako.error_handler`` _ |
+| |
+| |
+| |
++-----------------------------+
+
+Mako Default Filters
+++++++++++++++++++++
+
+List of string filter names that will be applied to all Mako expressions.
+
++-----------------------------+
+| Config File Setting Name |
++=============================+
+| ``mako.default_filters`` _ |
+| |
+| |
+| |
++-----------------------------+
+
+Mako Import
++++++++++++
+
+String list of Python statements, typically individual “import” lines, which
+will be placed into the module level preamble of all generated Python modules.
+
+
++-----------------------------+
+| Config File Setting Name |
++=============================+
+| ``mako.imports``________ _ |
+| |
+| |
+| |
++-----------------------------+
+
Examples
--------
diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py
index b63009e2c..e2330f3ad 100644
--- a/pyramid/mako_templating.py
+++ b/pyramid/mako_templating.py
@@ -64,6 +64,9 @@ def renderer_factory(info):
directories = settings.get('mako.directories')
module_directory = settings.get('mako.module_directory')
input_encoding = settings.get('mako.input_encoding', 'utf-8')
+ error_handler = settings.get('mako.error_handler', None)
+ default_filters = settings.get('mako.default_filters', [])
+ imports = settings.get('mako.imports', [])
if directories is None:
raise ConfigurationError(
'Mako template used without a ``mako.directories`` setting')
@@ -72,6 +75,9 @@ def renderer_factory(info):
lookup = PkgResourceTemplateLookup(directories=directories,
module_directory=module_directory,
input_encoding=input_encoding,
+ error_handler=error_handler,
+ default_filters=default_filters,
+ imports=imports,
filesystem_checks=reload_templates)
registry_lock.acquire()
try: