diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-29 03:16:10 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-29 03:16:10 +0000 |
| commit | 6cc96689989a7781f1da4ae05b0fbc38e6c8fdb9 (patch) | |
| tree | af261e74583d89393af8eb43421e7ce007785ff6 /repoze | |
| parent | 2869fc2f7f8fa9a4230d66859f232fe2e764103f (diff) | |
| download | pyramid-6cc96689989a7781f1da4ae05b0fbc38e6c8fdb9.tar.gz pyramid-6cc96689989a7781f1da4ae05b0fbc38e6c8fdb9.tar.bz2 pyramid-6cc96689989a7781f1da4ae05b0fbc38e6c8fdb9.zip | |
Add changelog entry for resource directive.
Rejigger error detection ordering.
Diffstat (limited to 'repoze')
| -rw-r--r-- | repoze/bfg/tests/test_zcml.py | 6 | ||||
| -rw-r--r-- | repoze/bfg/zcml.py | 24 |
2 files changed, 16 insertions, 14 deletions
diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py index 875628f5f..a8eec3d48 100644 --- a/repoze/bfg/tests/test_zcml.py +++ b/repoze/bfg/tests/test_zcml.py @@ -864,12 +864,14 @@ class TestResourceDirective(unittest.TestCase): def test_override_directory_with_file(self): from zope.configuration.exceptions import ConfigurationError context = DummyContext() - self.assertRaises(ConfigurationError, self._callFUT, context, 'a/', 'a') + self.assertRaises(ConfigurationError, self._callFUT, context, + 'a:foo/', 'a:foo.pt') def test_override_file_with_directory(self): from zope.configuration.exceptions import ConfigurationError context = DummyContext() - self.assertRaises(ConfigurationError, self._callFUT, context, 'a', 'a/') + self.assertRaises(ConfigurationError, self._callFUT, context, + 'a:foo.pt', 'a:foo/') def test_no_colons(self): from repoze.bfg.zcml import _override diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 38db4ead7..14b843bb1 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -192,18 +192,6 @@ def resource(context, to_override, override_with): if to_override == override_with: raise ConfigurationError('You cannot override a resource with itself') - if to_override.endswith('/'): - if not override_with.endswith('/'): - raise ConfigurationError( - 'A directory cannot be overridden with a file (put a slash ' - 'at the end of override_with if necessary)') - - if override_with.endswith('/'): - if not to_override.endswith('/'): - raise ConfigurationError( - 'A file cannot be overridden with a directory (put a slash ' - 'at the end of to_override if necessary)') - package = to_override path = '' if ':' in to_override: @@ -214,6 +202,18 @@ def resource(context, to_override, override_with): if ':' in override_with: override_package, override_prefix = override_with.split(':', 1) + if path.endswith('/'): + if not override_prefix.endswith('/'): + raise ConfigurationError( + 'A directory cannot be overridden with a file (put a slash ' + 'at the end of override_with if necessary)') + + if override_prefix.endswith('/'): + if not path.endswith('/'): + raise ConfigurationError( + 'A file cannot be overridden with a directory (put a slash ' + 'at the end of to_override if necessary)') + package = context.resolve(package).__name__ override_package = context.resolve(package).__name__ |
