summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-12-04 16:21:01 +0000
committerChris McDonough <chrism@agendaless.com>2009-12-04 16:21:01 +0000
commitb541caecff9ecd14545ca16f9fe278c29fbaf4a3 (patch)
treeba28ecbfbb38e104889fc91093b911806b1c1c71
parentab4e7b9befb1b84deedfcb29766e8250113ba566 (diff)
downloadpyramid-b541caecff9ecd14545ca16f9fe278c29fbaf4a3.tar.gz
pyramid-b541caecff9ecd14545ca16f9fe278c29fbaf4a3.tar.bz2
pyramid-b541caecff9ecd14545ca16f9fe278c29fbaf4a3.zip
- Operation on GAE was broken, presumably because the
``repoze.bfg.configuration`` module began to attempt to import the ``repoze.bfg.chameleon_zpt`` and ``repoze.bfg.chameleon_text`` modules, and these cannot be used on non-CPython platforms. It now tolerates startup time import failures for these modules, and only raise an import error when a template from one of these packages is actually used.
-rw-r--r--CHANGES.txt11
-rw-r--r--repoze/bfg/chameleon_text.py16
-rw-r--r--repoze/bfg/chameleon_zpt.py8
-rw-r--r--repoze/bfg/compat/__init__.py2
-rw-r--r--repoze/bfg/tests/test_compat.py5
-rw-r--r--repoze/bfg/tests/test_configuration.py3
6 files changed, 38 insertions, 7 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index db7415a2f..eb6c714ba 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,17 @@ Features
attached to the constructed model via
``zope.interface.alsoProvides``).
+Bug Fixes
+---------
+
+- Operation on GAE was broken, presumably because the
+ ``repoze.bfg.configuration`` module began to attempt to import the
+ ``repoze.bfg.chameleon_zpt`` and ``repoze.bfg.chameleon_text``
+ modules, and these cannot be used on non-CPython platforms. It now
+ tolerates startup time import failures for these modules, and only
+ raise an import error when a template from one of these packages is
+ actually used.
+
1.2a3 (2009-01-02)
==================
diff --git a/repoze/bfg/chameleon_text.py b/repoze/bfg/chameleon_text.py
index b69e8fed0..50491a3d0 100644
--- a/repoze/bfg/chameleon_text.py
+++ b/repoze/bfg/chameleon_text.py
@@ -2,8 +2,20 @@ from webob import Response
from zope.interface import implements
-from chameleon.core.template import TemplateFile
-from chameleon.zpt.language import Parser
+try:
+ from chameleon.core.template import TemplateFile
+except ImportError, why: # pragma: no cover
+ # Chameleon doesn't work on non-CPython platforms
+ class TemplateFile(object):
+ def __init__(self, *arg, **kw):
+ raise ImportError(why[0])
+
+try:
+ from chameleon.zpt.language import Parser
+except ImportError: # pragma: no cover
+ # Chameleon doesn't work on non-CPython platforms
+ class Parser(object):
+ pass
from repoze.bfg.interfaces import IResponseFactory
from repoze.bfg.interfaces import ITemplateRenderer
diff --git a/repoze/bfg/chameleon_zpt.py b/repoze/bfg/chameleon_zpt.py
index 270ad6394..bc1a5d22f 100644
--- a/repoze/bfg/chameleon_zpt.py
+++ b/repoze/bfg/chameleon_zpt.py
@@ -2,7 +2,13 @@ from webob import Response
from zope.interface import implements
-from chameleon.zpt.template import PageTemplateFile
+try:
+ from chameleon.zpt.template import PageTemplateFile
+except ImportError, why: # pragma: no cover
+ # Chameleon doesn't work on non-CPython platforms
+ class PageTemplateFile(object):
+ def __init__(self, *arg, **kw):
+ raise ImportError(why[0])
from repoze.bfg.interfaces import IResponseFactory
from repoze.bfg.interfaces import ITemplateRenderer
diff --git a/repoze/bfg/compat/__init__.py b/repoze/bfg/compat/__init__.py
index d2e47d9e5..ed5eabd8a 100644
--- a/repoze/bfg/compat/__init__.py
+++ b/repoze/bfg/compat/__init__.py
@@ -139,4 +139,4 @@ try:
from pkgutil import walk_packages
except ImportError:
from pkgutil_26 import walk_packages
-
+
diff --git a/repoze/bfg/tests/test_compat.py b/repoze/bfg/tests/test_compat.py
index cbee29654..66ea61860 100644
--- a/repoze/bfg/tests/test_compat.py
+++ b/repoze/bfg/tests/test_compat.py
@@ -1,10 +1,9 @@
import unittest
-class TestAll(unittest.TestCase):
- def test_it(self):
+class TestAliases(unittest.TestCase):
+ def test_all(self):
from repoze.bfg.compat import all
self.assertEqual(all([True, True]), True)
self.assertEqual(all([False, False]), False)
self.assertEqual(all([False, True]), False)
-
diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py
index da2f1d2c4..4523fe463 100644
--- a/repoze/bfg/tests/test_configuration.py
+++ b/repoze/bfg/tests/test_configuration.py
@@ -84,6 +84,9 @@ class ConfiguratorTests(unittest.TestCase):
self.failUnless(config.registry.getUtility(ISettings))
self.assertEqual(config.package, this_pkg)
self.failUnless(config.registry.getUtility(IRendererFactory, 'json'))
+ self.failUnless(config.registry.getUtility(IRendererFactory, 'string'))
+ self.failUnless(config.registry.getUtility(IRendererFactory, '.pt'))
+ self.failUnless(config.registry.getUtility(IRendererFactory, '.txt'))
def test_ctor_with_package_registry(self):
import sys