summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-29 17:47:35 -0500
committerChris McDonough <chrism@plope.com>2010-12-29 17:47:35 -0500
commit1f8536956af7e122007da369d35924c28dd99c25 (patch)
tree210eb215e04cdf44ccde62fa9221ac8e5749418a
parent613287762f6ca2f8d50651fc0b4eee2e9a5f8772 (diff)
downloadpyramid-1f8536956af7e122007da369d35924c28dd99c25.tar.gz
pyramid-1f8536956af7e122007da369d35924c28dd99c25.tar.bz2
pyramid-1f8536956af7e122007da369d35924c28dd99c25.zip
simplify guard logic for __action_decorator__
-rw-r--r--pyramid/config.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/pyramid/config.py b/pyramid/config.py
index e1005102b..e717556d9 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -4,7 +4,6 @@ import re
import sys
import threading
import traceback
-from types import FunctionType
import venusian
@@ -940,14 +939,17 @@ class Configurator(object):
action_decorator = getattr(handler, '__action_decorator__', None)
if action_decorator is not None:
- class_or_static = getattr(action_decorator, 'im_self',
- None) is not None
- if not class_or_static:
- class_or_static = isinstance(action_decorator, FunctionType)
- if not class_or_static:
- raise ConfigurationError(
- 'The "__action_decorator__" callable on a handler class '
- 'MUST be defined as a classmethod or a staticmethod.')
+ if hasattr(action_decorator, 'im_self'):
+ # instance methods have an im_self == None
+ # classmethods have an im_self == cls
+ # staticmethods have no im_self
+ # instances have no im_self
+ if action_decorator.im_self is not handler:
+ raise ConfigurationError(
+ 'The "__action_decorator__" attribute of a handler '
+ 'must not be an instance method (must be a '
+ 'staticmethod, classmethod, function, or an instance '
+ 'which is a callable')
path_has_action = ':action' in pattern or '{action}' in pattern