summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2011-08-12 03:19:17 -0500
committerMichael Merickel <michael@merickel.org>2011-08-12 03:19:17 -0500
commit352d516f90ec3420e637cc237e42c4fab081ad17 (patch)
tree3440b840e9940362b30ce3f2598586058441130e
parent9ec766cf34014de1e357a449133830ff944efb19 (diff)
downloadpyramid-352d516f90ec3420e637cc237e42c4fab081ad17.tar.gz
pyramid-352d516f90ec3420e637cc237e42c4fab081ad17.tar.bz2
pyramid-352d516f90ec3420e637cc237e42c4fab081ad17.zip
Added checks to config.add_tween for over/under ingress/main.
-rw-r--r--pyramid/config.py4
-rw-r--r--pyramid/tests/test_config.py16
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