- 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).
| | |
| | | ``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 |
| | | ------------- |
| | | |
| | |
| | | |
| | | - 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 |
| | | ----------- |
| | | |
| | |
| | | |
| | | 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 |
| | | |
| | | |
| | |
| | | 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): |
| | |
| | | |
| | | 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 |