summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-11-20 13:52:03 -0500
committerChris McDonough <chrism@plope.com>2010-11-20 13:52:03 -0500
commit35ce2adb609bfb3db346bc8cc937d13a0d2dddcd (patch)
treed95552d47840c9f0923b5ca912dde0b80654e287
parent12f38891a8c478787b06073d2d443827bbb95fb0 (diff)
downloadpyramid-35ce2adb609bfb3db346bc8cc937d13a0d2dddcd.tar.gz
pyramid-35ce2adb609bfb3db346bc8cc937d13a0d2dddcd.tar.bz2
pyramid-35ce2adb609bfb3db346bc8cc937d13a0d2dddcd.zip
- Fix configurator to not convert ``ImportError`` to ``ConfigurationError``
if the import that failed was unrelated to the import requested via a dotted name when resolving dotted names (such as view dotted names).
-rw-r--r--CHANGES.txt4
-rw-r--r--TODO.txt4
-rw-r--r--pyramid/configuration.py12
-rw-r--r--pyramid/tests/test_configuration.py7
4 files changed, 10 insertions, 17 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 692e3cc35..aee0fae2f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -30,6 +30,10 @@ Features
``config.end()`` is no longer necessary. All paster templates have been
changed to no longer call these functions.
+- Fix configurator to not convert ``ImportError`` to ``ConfigurationError``
+ if the import that failed was unrelated to the import requested via a
+ dotted name when resolving dotted names (such as view dotted names).
+
Documentation
-------------
diff --git a/TODO.txt b/TODO.txt
index f1db6f758..e1692695c 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -37,10 +37,6 @@ Must-Have (before 1.0)
- Better ``config.add_handler`` documentation.
-- Fix DottedNameResolver to not convert ImportError to ConfigurationError if
- the import that failed was unrelated to the import requested via a dotted
- name.
-
Should-Have
-----------
diff --git a/pyramid/configuration.py b/pyramid/configuration.py
index 63d09efe3..c7505b9db 100644
--- a/pyramid/configuration.py
+++ b/pyramid/configuration.py
@@ -2844,14 +2844,10 @@ class DottedNameResolver(object):
def maybe_resolve(self, dotted):
if isinstance(dotted, basestring):
- try:
- if ':' in dotted:
- return self._pkg_resources_style(dotted)
- else:
- return self._zope_dottedname_style(dotted)
- except ImportError:
- raise ConfigurationError(
- 'The dotted name %r cannot be imported' % (dotted,))
+ if ':' in dotted:
+ return self._pkg_resources_style(dotted)
+ else:
+ return self._zope_dottedname_style(dotted)
return dotted
diff --git a/pyramid/tests/test_configuration.py b/pyramid/tests/test_configuration.py
index a8ea63f54..4c1182eab 100644
--- a/pyramid/tests/test_configuration.py
+++ b/pyramid/tests/test_configuration.py
@@ -216,9 +216,8 @@ class ConfiguratorTests(unittest.TestCase):
self.assertEqual(result, pyramid.tests)
def test_maybe_dotted_string_fail(self):
- from pyramid.configuration import ConfigurationError
config = self._makeOne()
- self.assertRaises(ConfigurationError,
+ self.assertRaises(ImportError,
config.maybe_dotted, 'cant.be.found')
def test_maybe_dotted_notstring_success(self):
@@ -4397,9 +4396,7 @@ class TestDottedNameResolver(unittest.TestCase):
def test_resolve_missing_raises(self):
typ = self._makeOne()
- e = self.config_exc(typ.resolve, 'cant.be.found')
- self.assertEqual(e.args[0],
- "The dotted name 'cant.be.found' cannot be imported")
+ self.assertRaises(ImportError, typ.resolve, 'cant.be.found')
def test_ctor_string_module_resolveable(self):
import pyramid.tests