mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
Add utilty function to get the handler method for a request.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user