From 688a93af3f074edb5ece07661c35fd2019a800f5 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sat, 11 May 2013 10:54:28 +0200 Subject: add missing word; be more precise --- pyramid/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyramid/testing.py b/pyramid/testing.py index 0c701727b..06b795f9a 100644 --- a/pyramid/testing.py +++ b/pyramid/testing.py @@ -482,9 +482,9 @@ def tearDown(unhook_zca=True): If the ``unhook_zca`` argument is ``True`` (the default), call :func:`zope.component.getSiteManager.reset`. This undoes the - action of :func:`pyramid.testing.setUp` called with the + action of :func:`pyramid.testing.setUp` when called with the argument ``hook_zca=True``. If :mod:`zope.component` cannot be - imported, ignore the argument. + imported, ``unhook_zca`` is set to ``False``. """ global have_zca if unhook_zca and have_zca: -- cgit v1.2.3 From 4e2f1f0660f77816958882459fd819f2928d0f19 Mon Sep 17 00:00:00 2001 From: Goodwill Coding Date: Thu, 16 May 2013 09:07:34 -0700 Subject: Extend informational message to pcreate output. Tutorial, docs, twitter, maillist. --- pyramid/scaffolds/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pyramid/scaffolds/__init__.py b/pyramid/scaffolds/__init__.py index dc207b540..a87041576 100644 --- a/pyramid/scaffolds/__init__.py +++ b/pyramid/scaffolds/__init__.py @@ -1,5 +1,6 @@ import binascii import os +from textwrap import dedent from pyramid.compat import native_ @@ -33,7 +34,22 @@ class PyramidTemplate(Template): """ Overrides :meth:`pyramid.scaffolds.template.Template.post`, to print "Welcome to Pyramid. Sorry for the convenience." after a successful scaffolding rendering.""" - self.out('Welcome to Pyramid. Sorry for the convenience.') + + separator = "=" * 79 + msg = dedent( + """ + %(separator)s + Tutorials: http://docs.pylonsproject.org/projects/pyramid_tutorials + Documentation: http://docs.pylonsproject.org/projects/pyramid + + Twitter (tips & updates): http://twitter.com/pylons + Mailing List: http://groups.google.com/group/pylons-discuss + + Welcome to Pyramid. Sorry for the convenience. + %(separator)s + """ % {'separator': separator}) + + self.out(msg) return Template.post(self, command, output_dir, vars) def out(self, msg): # pragma: no cover (replaceable testing hook) -- cgit v1.2.3 From 647063576a476bba503fc836839d002a7e7368c8 Mon Sep 17 00:00:00 2001 From: Goodwill Coding Date: Thu, 16 May 2013 09:10:17 -0700 Subject: fix indentaion type --- pyramid/scaffolds/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyramid/scaffolds/__init__.py b/pyramid/scaffolds/__init__.py index a87041576..c993ce5f9 100644 --- a/pyramid/scaffolds/__init__.py +++ b/pyramid/scaffolds/__init__.py @@ -47,7 +47,7 @@ class PyramidTemplate(Template): Welcome to Pyramid. Sorry for the convenience. %(separator)s - """ % {'separator': separator}) + """ % {'separator': separator}) self.out(msg) return Template.post(self, command, output_dir, vars) -- cgit v1.2.3 From 45ef9a69e51189051c03b3fdeac4458ee94d7529 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 21 May 2013 15:27:02 -0400 Subject: Prevent non-3.2-compatible MarkupSafe 0.16 from breaking us. Apps which actually use Mako templates are still broken. --- CHANGES.txt | 3 +++ pyramid/mako_templating.py | 29 +++++++++++++++++++++++++---- 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] ) -- cgit v1.2.3 From 81c75fd1662b5b0a91616289dc44c808bb9be01a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 21 May 2013 17:58:40 -0400 Subject: skip mako-related tests on py32 --- pyramid/mako_templating.py | 1 - .../pkgs/viewdecoratorapp/views/templates/foo.mak | 3 --- .../pkgs/viewdecoratorapp/views/templates/foo.pt | 3 +++ pyramid/tests/pkgs/viewdecoratorapp/views/views.py | 4 ++-- pyramid/tests/test_integration.py | 10 ---------- pyramid/tests/test_mako_templating.py | 23 +++++++++++++++++----- 6 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.mak create mode 100644 pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.pt diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index 5fbdd002e..69b48a3b5 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -1,6 +1,5 @@ import os import posixpath -import re import sys import threading diff --git a/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.mak b/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.mak deleted file mode 100644 index 6a2f701b6..000000000 --- a/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.mak +++ /dev/null @@ -1,3 +0,0 @@ - -${result} - diff --git a/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.pt b/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.pt new file mode 100644 index 000000000..6a2f701b6 --- /dev/null +++ b/pyramid/tests/pkgs/viewdecoratorapp/views/templates/foo.pt @@ -0,0 +1,3 @@ + +${result} + diff --git a/pyramid/tests/pkgs/viewdecoratorapp/views/views.py b/pyramid/tests/pkgs/viewdecoratorapp/views/views.py index 6f7ff1e21..2b7d7e928 100644 --- a/pyramid/tests/pkgs/viewdecoratorapp/views/views.py +++ b/pyramid/tests/pkgs/viewdecoratorapp/views/views.py @@ -1,11 +1,11 @@ from pyramid.view import view_config -@view_config(renderer='templates/foo.mak', name='first') +@view_config(renderer='templates/foo.pt', name='first') def first(request): return {'result':'OK1'} @view_config( - renderer='pyramid.tests.pkgs.viewdecoratorapp.views:templates/foo.mak', + renderer='pyramid.tests.pkgs.viewdecoratorapp.views:templates/foo.pt', name='second') def second(request): return {'result':'OK2'} diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index c8418c61d..66205e618 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -369,22 +369,12 @@ class TestForbiddenAppHasResult(IntegrationBase, unittest.TestCase): class TestViewDecoratorApp(IntegrationBase, unittest.TestCase): package = 'pyramid.tests.pkgs.viewdecoratorapp' - def _configure_mako(self): - tmpldir = os.path.join(os.path.dirname(__file__), - 'pkgs', - 'viewdecoratorapp', - 'views') - self.config.registry.settings['mako.directories'] = tmpldir def test_first(self): - # we use mako here instead of chameleon because it works on Jython - self._configure_mako() res = self.testapp.get('/first', status=200) self.assertTrue(b'OK' in res.body) def test_second(self): - # we use mako here instead of chameleon because it works on Jython - self._configure_mako() res = self.testapp.get('/second', status=200) self.assertTrue(b'OK2' in res.body) diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index 50ef360d9..75faa771d 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -22,7 +22,20 @@ class Base(object): def tearDown(self): self.config.end() -class Test_renderer_factory(Base, unittest.TestCase): +def maybe_unittest(): + # The latest release of MarkupSafe (0.17) which is used by Mako is + # incompatible with Python 3.2, so we skip these tests if we cannot + # import a Mako module which ends up importing MarkupSafe. Note that + # this version of MarkupSafe *is* compatible with Python 2.6, 2.7, and 3.3, + # so these tests should not be skipped on those platforms. + try: + import mako.lookup + except (ImportError, SyntaxError, AttributeError): + return object + else: + return unittest.TestCase + +class Test_renderer_factory(Base, maybe_unittest()): def _callFUT(self, info): from pyramid.mako_templating import renderer_factory return renderer_factory(info) @@ -298,7 +311,7 @@ class Test_renderer_factory(Base, unittest.TestCase): self.assertEqual(result.path, 'hello .world.mako') self.assertEqual(result.defname, 'comp') -class MakoRendererFactoryHelperTests(Base, unittest.TestCase): +class MakoRendererFactoryHelperTests(Base, maybe_unittest()): def _getTargetClass(self): from pyramid.mako_templating import MakoRendererFactoryHelper return MakoRendererFactoryHelper @@ -345,7 +358,7 @@ class MakoRendererFactoryHelperTests(Base, unittest.TestCase): self.assertEqual(renderer.path, 'helloworld.mak') self.assertEqual(renderer.lookup, lookup) -class MakoLookupTemplateRendererTests(Base, unittest.TestCase): +class MakoLookupTemplateRendererTests(Base, maybe_unittest()): def _getTargetClass(self): from pyramid.mako_templating import MakoLookupTemplateRenderer return MakoLookupTemplateRenderer @@ -426,7 +439,7 @@ class MakoLookupTemplateRendererTests(Base, unittest.TestCase): self.assertTrue(isinstance(result, text_type)) self.assertEqual(result, text_('result')) -class TestIntegration(unittest.TestCase): +class TestIntegration(maybe_unittest()): def setUp(self): import pyramid.mako_templating self.config = testing.setUp() @@ -501,7 +514,7 @@ class TestIntegration(unittest.TestCase): {'name':'fred'}).replace('\r','') self.assertEqual(result, text_('Hello, <b>fred</b>!\n')) -class TestPkgResourceTemplateLookup(unittest.TestCase): +class TestPkgResourceTemplateLookup(maybe_unittest()): def _makeOne(self, **kw): from pyramid.mako_templating import PkgResourceTemplateLookup return PkgResourceTemplateLookup(**kw) -- cgit v1.2.3 From 0fdb540f8e432061ec09623f0275a6b6555292ef Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 21 May 2013 18:17:57 -0400 Subject: tortured docs --- CHANGES.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 2c4f4e31c..468fe1ed1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -32,8 +32,11 @@ Features Bug Fixes --------- -- ``mako_templating``: added defensive workaround for non-importability - of ``mako`` (due to upstream ``markupsafe`` dropping Python 3.2 support). +- ``mako_templating``: added defensive workaround for non-importability of + ``mako`` due to upstream ``markupsafe`` dropping Python 3.2 support. Mako + templating will no longer work under the combination of MarkupSafe 0.17 and + Python 3.2 (although the combination of MarkupSafe 0.17 and Python 3.3 or any + supported Python 2 version will work OK). - 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 -- cgit v1.2.3