Chris McDonough
2010-11-20 35ce2adb609bfb3db346bc8cc937d13a0d2dddcd
- 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).
4 files modified
27 ■■■■■ changed files
CHANGES.txt 4 ●●●● patch | view | raw | blame | history
TODO.txt 4 ●●●● patch | view | raw | blame | history
pyramid/configuration.py 12 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_configuration.py 7 ●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -30,6 +30,10 @@
  ``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
-------------
TODO.txt
@@ -37,10 +37,6 @@
- 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
-----------
pyramid/configuration.py
@@ -2844,14 +2844,10 @@
    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
pyramid/tests/test_configuration.py
@@ -216,9 +216,8 @@
        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 @@
    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