From 352d516f90ec3420e637cc237e42c4fab081ad17 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 12 Aug 2011 03:19:17 -0500 Subject: Added checks to config.add_tween for over/under ingress/main. --- pyramid/config.py | 4 ++-- pyramid/tests/test_config.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pyramid/config.py b/pyramid/config.py index 3c6e8db6f..4fbcd2819 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -1050,10 +1050,10 @@ class Configurator(object): if alias in (MAIN, INGRESS): raise ConfigurationError('%s is a reserved tween name' % alias) - if over is INGRESS: + if over is INGRESS or hasattr(over, '__iter__') and INGRESS in over: raise ConfigurationError('%s cannot be over INGRESS' % name) - if under is MAIN: + if under is MAIN or hasattr(under, '__iter__') and MAIN in under: raise ConfigurationError('%s cannot be under MAIN' % name) registry = self.registry diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 5f5bbdc53..5eac64520 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -752,6 +752,14 @@ pyramid.tests.test_config.dummy_include2""", config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory', over=INGRESS) + def test_add_tween_over_ingress_iterable(self): + from pyramid.exceptions import ConfigurationError + from pyramid.tweens import INGRESS + config = self._makeOne() + self.assertRaises(ConfigurationError, + config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory', + over=('a', INGRESS)) + def test_add_tween_under_main(self): from pyramid.exceptions import ConfigurationError from pyramid.tweens import MAIN @@ -760,6 +768,14 @@ pyramid.tests.test_config.dummy_include2""", config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory', under=MAIN) + def test_add_tween_under_main_iterable(self): + from pyramid.exceptions import ConfigurationError + from pyramid.tweens import MAIN + config = self._makeOne() + self.assertRaises(ConfigurationError, + config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory', + under=('a', MAIN)) + def test_add_subscriber_defaults(self): from zope.interface import implements from zope.interface import Interface -- cgit v1.2.3