[TurboGears2] Update the no-chameleon patch

Luke Macken lmacken at fedoraproject.org
Mon Apr 8 21:26:50 UTC 2013


commit 7d9a2bd54797ea6272e4701ad2044c37c28af4b0
Author: Luke Macken <lmacken at redhat.com>
Date:   Mon Apr 8 16:21:04 2013 -0400

    Update the no-chameleon patch

 TurboGears2-no-chameleon.patch |  230 ++++++++++++++++++++++++++++++++++------
 1 files changed, 199 insertions(+), 31 deletions(-)
---
diff --git a/TurboGears2-no-chameleon.patch b/TurboGears2-no-chameleon.patch
index 27ec09f..7107dfd 100644
--- a/TurboGears2-no-chameleon.patch
+++ b/TurboGears2-no-chameleon.patch
@@ -1,59 +1,114 @@
-diff -up ./tests/test_configuration.py.orig ./tests/test_configuration.py
---- ./tests/test_configuration.py.orig	2011-12-14 14:23:02.695929669 -0500
-+++ ./tests/test_configuration.py	2011-12-14 14:23:07.036941896 -0500
-@@ -98,10 +98,6 @@ class TestAppConfig:
+diff -Naur TurboGears2-2.3.0dev.orig/setup.py TurboGears2-2.3.0dev/setup.py
+--- TurboGears2-2.3.0dev.orig/setup.py	2013-04-03 13:56:25.379430738 -0400
++++ TurboGears2-2.3.0dev/setup.py	2013-04-03 13:56:32.489528286 -0400
+@@ -31,7 +31,6 @@
+ if py_version[0] == 2:
+     test_requirements.extend(['TurboKid >= 1.0.4',
+                               'Kajiki >= 0.2.2',
+-                              'Chameleon < 2.0a',
+                               'simplegeneric',
+                               'Formencode',
+                               'routes',
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_configuration.py TurboGears2-2.3.0dev/tests/test_configuration.py
+--- TurboGears2-2.3.0dev.orig/tests/test_configuration.py	2013-04-03 13:56:25.378430724 -0400
++++ TurboGears2-2.3.0dev/tests/test_configuration.py	2013-04-03 13:57:20.414184664 -0400
+@@ -217,12 +217,6 @@
      def test_setup_sa_auth_backend(self):
          self.config.setup_sa_auth_backend()
  
 -    def test_setup_chameleon_genshi_renderer(self):
+-        if PY3: raise SkipTest()
+-
 -        self.config.paths.templates = 'template_path'
 -        self.config.setup_chameleon_genshi_renderer()
 -
-     def test_setup_genshi_renderer(self):
-         self.config.paths.templates = 'template_path'
-         self.config.setup_genshi_renderer()
-diff -up ./tests/test_stack/__init__.py.orig ./tests/test_stack/__init__.py
---- ./tests/test_stack/__init__.py.orig	2011-12-14 14:23:33.518017884 -0500
-+++ ./tests/test_stack/__init__.py	2011-12-14 14:23:44.810051011 -0500
-@@ -12,7 +12,7 @@ class TestConfig(AppConfig):
-             values = {}
-         AppConfig.__init__(self)
+     def test_setup_kajiki_renderer(self):
+         if PY3: raise SkipTest()
+ 
+@@ -910,4 +904,4 @@
+         conf = AppConfig(minimal=True, root_controller=RootController())
+         conf.package = sys.modules[__name__]
+ 
+-        app = conf.make_wsgi_app()
+\ No newline at end of file
++        app = conf.make_wsgi_app()
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_stack/__init__.py TurboGears2-2.3.0dev/tests/test_stack/__init__.py
+--- TurboGears2-2.3.0dev.orig/tests/test_stack/__init__.py	2013-04-03 13:56:25.374430669 -0400
++++ TurboGears2-2.3.0dev/tests/test_stack/__init__.py	2013-04-03 13:57:38.053425778 -0400
+@@ -16,7 +16,7 @@
          #First we setup some base values that we know will work
--        self.renderers = ['genshi', 'mako', 'chameleon_genshi', 'jinja','json']
-+        self.renderers = ['genshi', 'mako', 'jinja','json']
+         self.renderers = ['genshi', 'mako', 'jinja','json']
+         if not PY3:
+-            self.renderers.extend(['chameleon_genshi', 'kajiki'])
++            self.renderers.extend(['kajiki'])
+ 
          self.render_functions = tg.util.Bunch()
          self.package = tests.test_stack
-         self.default_renderer = 'genshi'
-diff -up ./tests/test_stack/rendering/test_dotted_rendering.py.orig ./tests/test_stack/rendering/test_dotted_rendering.py
---- ./tests/test_stack/rendering/test_dotted_rendering.py.orig	2011-12-14 14:22:47.881888440 -0500
-+++ ./tests/test_stack/rendering/test_dotted_rendering.py	2011-12-14 14:22:51.137897436 -0500
-@@ -15,12 +15,6 @@ def setup_noDB():
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/controllers/root.py TurboGears2-2.3.0dev/tests/test_stack/rendering/controllers/root.py
+--- TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/controllers/root.py	2013-04-03 13:56:25.376430697 -0400
++++ TurboGears2-2.3.0dev/tests/test_stack/rendering/controllers/root.py	2013-04-03 14:01:17.829412104 -0400
+@@ -261,14 +261,6 @@
+         i18n.set_temporary_lang("de")
+         return {}
+ 
+-    @expose('chameleon_genshi:index.html')
+-    def chameleon_genshi_index(self):
+-        return {}
+-
+-    @expose('chameleon_genshi:genshi_inherits.html')
+-    def chameleon_genshi_inherits(self):
+-        return {}
+-
+     @expose('mako:mako_noop.mak')
+     def mako_index(self):
+         return {}
+@@ -277,10 +269,6 @@
+     def mako_inherits(self):
+         return {}
+ 
+-    @expose('chameleon_genshi:tests.test_stack.rendering.templates.index')
+-    def chameleon_index_dotted(self):
+-        return {}
+-
+     @expose('kajiki:tests.test_stack.rendering.templates.index')
+     def kajiki_index_dotted(self):
+         return {}
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/test_dotted_rendering.py TurboGears2-2.3.0dev/tests/test_stack/rendering/test_dotted_rendering.py
+--- TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/test_dotted_rendering.py	2013-04-03 13:56:25.375430683 -0400
++++ TurboGears2-2.3.0dev/tests/test_stack/rendering/test_dotted_rendering.py	2013-04-03 13:58:32.815172826 -0400
+@@ -19,14 +19,6 @@
                               )
      return app_from_config(base_config)
  
 -def test_default_chameleon_genshi_renderer():
+-    if PY3: raise SkipTest()
+-
 -    app = setup_noDB()
 -    resp = app.get('/chameleon_index_dotted')
 -    assert "Welcome" in resp, resp
 -    assert "TurboGears" in resp, resp
 -
- #def test_default_kajiki_renderer():
- #    app = setup_noDB()
- #    resp = app.get('/kajiki_index_dotted')
-diff -up ./tests/test_stack/rendering/test_rendering.py.orig ./tests/test_stack/rendering/test_rendering.py
---- ./tests/test_stack/rendering/test_rendering.py.orig	2011-12-14 14:22:34.263851224 -0500
-+++ ./tests/test_stack/rendering/test_rendering.py	2011-12-14 14:22:42.533873747 -0500
-@@ -122,34 +122,6 @@ def test_genshi_sub_inheritance_from_bot
+ def test_default_kajiki_renderer():
+     if PY3: raise SkipTest()
+ 
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/test_rendering.py TurboGears2-2.3.0dev/tests/test_stack/rendering/test_rendering.py
+--- TurboGears2-2.3.0dev.orig/tests/test_stack/rendering/test_rendering.py	2013-04-03 13:56:25.375430683 -0400
++++ TurboGears2-2.3.0dev/tests/test_stack/rendering/test_rendering.py	2013-04-03 13:59:11.121694138 -0400
+@@ -256,38 +256,6 @@
      assert "from sub-template: sub.frombottom" in resp
      assert "Master template" in resp
  
 -def test_chameleon_genshi_base():
+-    if PY3: raise SkipTest()
+-
 -    app = setup_noDB()
 -    resp = app.get('/chameleon_genshi_index')
 -    assert ("<p>TurboGears 2 is rapid web application development toolkit"
 -        " designed to make your life easier.</p>") in resp
 -
 -def test_chameleon_genshi_inheritance():
+-    if PY3: raise SkipTest()
+-
 -    try:
 -        import lxml
 -    except ImportError:
@@ -63,11 +118,11 @@ diff -up ./tests/test_stack/rendering/test_rendering.py.orig ./tests/test_stack/
 -    app = setup_noDB()
 -    try:
 -        resp = app.get('/chameleon_genshi_inherits')
--    except NameError, e:
+-    except NameError as e:
 -        # known issue with chameleon.genshi 1.0
 -        if 'match_templates' not in str(e):
 -            raise
--    except AttributeError, e:
+-    except AttributeError as e:
 -        # known issue with chameleon.genshi 1.3
 -        if 'XPathResult' not in str(e):
 -            raise
@@ -75,6 +130,119 @@ diff -up ./tests/test_stack/rendering/test_rendering.py.orig ./tests/test_stack/
 -        assert "Inheritance template" in resp
 -        assert "Master template" in resp
 -
- def _test_jinja_inherits():
+ def test_jinja_autoload():
      app = setup_noDB()
-     resp = app.get('/jinja_inherits')
+     resp = app.get('/jinja_autoload', status=500)
+diff -Naur TurboGears2-2.3.0dev.orig/tg/configuration/app_config.py TurboGears2-2.3.0dev/tg/configuration/app_config.py
+--- TurboGears2-2.3.0dev.orig/tg/configuration/app_config.py	2013-04-03 13:56:25.365430546 -0400
++++ TurboGears2-2.3.0dev/tg/configuration/app_config.py	2013-04-03 14:00:22.104657686 -0400
+@@ -512,25 +512,6 @@
+ 
+         self.render_functions.mako = render_mako
+ 
+-    def setup_chameleon_genshi_renderer(self): #pragma: no cover
+-        """Setup a renderer and loader for the chameleon.genshi engine."""
+-        from tg.render import RenderChameleonGenshi
+-
+-        try:
+-            import chameleon.genshi.loader
+-        except ImportError:
+-            return False
+-
+-        if config.get('use_dotted_templatenames', True):
+-            from tg.dottednames.chameleon_genshi_lookup \
+-                import ChameleonGenshiTemplateLoader as TemplateLoader
+-        else:
+-            from chameleon.genshi.loader import TemplateLoader
+-        loader = TemplateLoader(search_path=self.paths.templates,
+-                                auto_reload=self.auto_reload_templates)
+-
+-        self.render_functions.chameleon_genshi = RenderChameleonGenshi(loader)
+-
+     def setup_genshi_renderer(self):
+         """Setup a renderer and loader for Genshi templates.
+ 
+diff -Naur TurboGears2-2.3.0dev.orig/tg/dottednames/chameleon_genshi_lookup.py TurboGears2-2.3.0dev/tg/dottednames/chameleon_genshi_lookup.py
+--- TurboGears2-2.3.0dev.orig/tg/dottednames/chameleon_genshi_lookup.py	2013-04-03 13:56:25.369430600 -0400
++++ TurboGears2-2.3.0dev/tg/dottednames/chameleon_genshi_lookup.py	1969-12-31 19:00:00.000000000 -0500
+@@ -1,29 +0,0 @@
+-"""Chameleon.Genshi template loader that supports dotted names."""
+-
+-from chameleon.genshi.loader import TemplateLoader
+-
+-from tg import config
+-
+-
+-class ChameleonGenshiTemplateLoader(TemplateLoader):
+-    """Chameleon.Genshi template loader supporting dotted filenames.
+-
+-    Supports zipped applications and dotted filenames as well as path names.
+-
+-    """
+-
+-    template_extension = '.html'
+-
+-    def get_dotted_filename(self, filename):
+-        if not filename.endswith(self.template_extension):
+-            finder = config['tg.app_globals'].dotted_filename_finder
+-            filename = finder.get_dotted_filename(
+-                    template_name=filename,
+-                    template_extension=self.template_extension)
+-        return filename
+-
+-    def load(self, filename, format='xml'):
+-        """Actual loader function."""
+-        return TemplateLoader.load(
+-                self, self.get_dotted_filename(filename), format)
+-
+diff -Naur TurboGears2-2.3.0dev.orig/tg/render.py TurboGears2-2.3.0dev/tg/render.py
+--- TurboGears2-2.3.0dev.orig/tg/render.py	2013-04-03 13:56:25.367430573 -0400
++++ TurboGears2-2.3.0dev/tg/render.py	2013-04-03 14:00:45.032968298 -0400
+@@ -222,47 +222,6 @@
+         return render_func()
+ 
+ 
+-class RenderChameleonGenshi(object): #pragma: no cover
+-    """Singleton that can be called as the Chameleon-Genshi render function."""
+-
+-    format_for_content_type = {
+-        'text/plain': 'text',
+-        'text/css': 'text',
+-        'text/html': 'xml',
+-        'text/xml': 'xml',
+-        'application/xml': 'xml',
+-        'application/xhtml+xml': 'xml',
+-        'application/atom+xml': 'xml',
+-        'application/rss+xml': 'xml',
+-        'application/soap+xml': 'xml',
+-        'image/svg+xml': 'xml'}
+-
+-    def __init__(self, loader):
+-        self.load_template = loader.load
+-
+-    def __call__(self, template_name, template_vars, **kwargs):
+-        """Render the template_vars with the Chameleon-Genshi template."""
+-        config = tg.config._current_obj()
+-
+-        # Gets template format from content type or from config options
+-        format = kwargs.get('format')
+-        if not format:
+-            format = self.format_for_content_type.get(tg.response.content_type)
+-            if not format:
+-                format = config.get('templating.chameleon.genshi.format')
+-                if not format:
+-                    format = config.get('templating.genshi.method')
+-                    if not format or format not in ('xml', 'text'):
+-                        format = 'xml'
+-
+-        def render_template():
+-            template = self.load_template(template_name, format=format)
+-            return Markup(template.render(**template_vars))
+-
+-        return cached_template(template_name, render_template,
+-                               ns_options=('doctype', 'method'), **kwargs)
+-
+-
+ class RenderGenshi(object):
+     """Singleton that can be called as the Genshi render function."""
+ 


More information about the scm-commits mailing list