summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyramid/config.py4
-rw-r--r--pyramid/tests/test_config.py11
2 files changed, 15 insertions, 0 deletions
diff --git a/pyramid/config.py b/pyramid/config.py
index 5c3bf7002..274938225 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -942,6 +942,10 @@ class Configurator(object):
pattern = route.pattern
action_decorator = getattr(handler, '_action_decorator', None)
+ if action_decorator is not None and action_decorator.im_self is None:
+ raise ConfigurationError(
+ 'The "_action_decorator" method on a handler class MUST be '
+ 'defined as a classmethod.')
path_has_action = ':action' in pattern or '{action}' in pattern
diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py
index 2bbd2e4aa..0a87f4d7f 100644
--- a/pyramid/tests/test_config.py
+++ b/pyramid/tests/test_config.py
@@ -1993,6 +1993,17 @@ class ConfiguratorTests(unittest.TestCase):
self.assertEqual(len(views), 1)
self.assertEqual(views[0]['decorator'], MyHandler._action_decorator)
+ def test_add_handler_with_action_decorator_no_classmethod(self):
+ config = self._makeOne(autocommit=True)
+ class MyHandler(object):
+ def _action_decorator(self, fn): # pragma: no cover
+ return fn
+ def action(self): # pragma: no cover
+ return 'response'
+ from pyramid.exceptions import ConfigurationError
+ self.assertRaises(ConfigurationError, config.add_handler,
+ 'name', '/{action}', MyHandler)
+
def test_add_handler_doesnt_mutate_expose_dict(self):
config = self._makeOne(autocommit=True)
views = []