Add utilty function to get the handler method for a request.

This commit is contained in:
Max Goodman
2011-10-25 10:40:23 -07:00
parent b57dff70a1
commit 0ebeda5e52
2 changed files with 6 additions and 1 deletions

View File

@@ -669,7 +669,7 @@ class MinimalController(BaseController):
action = request.environ["pylons.routes_dict"]["action_name"]
handler = getattr(self, method + "_" + action, None)
handler = self._get_action_handler(action, method)
cors = handler and getattr(handler, "cors_perms", None)
if cors and cors["origin_check"](origin):

View File

@@ -118,6 +118,11 @@ class BaseController(WSGIController):
def pre(self): pass
def post(self): pass
def _get_action_handler(self, name=None, method=None):
name = name or request.environ["pylons.routes_dict"]["action_name"]
method = method or request.method
action = method + "_" + name
return getattr(self, action, None)
@classmethod
def format_output_url(cls, url, **kw):