summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-05-21 16:06:53 -0400
committerChris McDonough <chrism@plope.com>2013-05-21 16:06:53 -0400
commit83f34df6fcf7c43ec2357eee5d777baebd602581 (patch)
treea6e440a79c767af099308294e6c9d66d89d20623
parent1f0106e2debcfc82e17c55385ce9a01985ae458c (diff)
parentda8bcf5bd8920c21c8f4691a31c73eb72b7e3eab (diff)
downloadpyramid-83f34df6fcf7c43ec2357eee5d777baebd602581.tar.gz
pyramid-83f34df6fcf7c43ec2357eee5d777baebd602581.tar.bz2
pyramid-83f34df6fcf7c43ec2357eee5d777baebd602581.zip
Merge branch 'master' of github.com:Pylons/pyramid
-rw-r--r--CHANGES.txt3
-rw-r--r--pyramid/mako_templating.py29
2 files changed, 28 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index e6dd9f0cb..2c4f4e31c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -32,6 +32,9 @@ Features
Bug Fixes
---------
+- ``mako_templating``: added defensive workaround for non-importability
+ of ``mako`` (due to upstream ``markupsafe`` dropping Python 3.2 support).
+
- View lookup will now search for valid views based on the inheritance
hierarchy of the context. It tries to find views based on the most
specific context first, and upon predicate failure, will move up the
diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py
index 061bcb717..5fbdd002e 100644
--- a/pyramid/mako_templating.py
+++ b/pyramid/mako_templating.py
@@ -23,8 +23,29 @@ from pyramid.interfaces import ITemplateRenderer
from pyramid.settings import asbool
from pyramid.util import DottedNameResolver
-from mako.lookup import TemplateLookup
-from mako import exceptions
+try:
+ from mako.lookup import TemplateLookup
+except (ImportError, SyntaxError, AttributeError): #pragma NO COVER
+ class TemplateLookup(object):
+ def __init__(self, **kw):
+ pass
+ def no_mako(self, *args, **kw):
+ raise NotImplementedError("'mako' not importable")
+ adjust_uri = get_template = filename_to_uri = no_mako
+ put_string = put_template = no_mako
+
+try:
+ from mako.exceptions import TopLevelLookupException
+except (ImportError, SyntaxError, AttributeError): #pragma NO COVER
+ class TopLevelLookupException(Exception):
+ pass
+
+try:
+ from mako.exceptions import text_error_template
+except (ImportError, SyntaxError, AttributeError): #pragma NO COVER
+ def text_error_template(lookup=None):
+ raise NotImplementedError("'mako' not importable")
+
class IMakoLookup(Interface):
pass
@@ -78,7 +99,7 @@ class PkgResourceTemplateLookup(TemplateLookup):
srcfile = abspath_from_asset_spec(path, pname)
if os.path.isfile(srcfile):
return self._load(srcfile, adjusted)
- raise exceptions.TopLevelLookupException(
+ raise TopLevelLookupException(
"Can not locate template for uri %r" % uri)
return TemplateLookup.get_template(self, uri)
@@ -208,7 +229,7 @@ class MakoLookupTemplateRenderer(object):
except:
try:
exc_info = sys.exc_info()
- errtext = exceptions.text_error_template().render(
+ errtext = text_error_template().render(
error=exc_info[1],
traceback=exc_info[2]
)