From 230da47d5b7b291ff13e88e9fdc547a9fd49c031 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 19 Feb 2015 20:37:39 -0600 Subject: [PATCH] app: Use _find_attr to locate controller's allowed_methods Using the `milla.app.Application._find_attr` method to find the `allowed_methods` of returned controller callables allows the attribute to be defined e.g. on the class for instance methods, etc. --- src/milla/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/milla/app.py b/src/milla/app.py index 80e7606..dc6ebc7 100644 --- a/src/milla/app.py +++ b/src/milla/app.py @@ -75,8 +75,10 @@ class Application(object): if request.method == 'POST' and '_method' in request.POST: request.method = request.POST.pop('_method') - allowed_methods = getattr(func, 'allowed_methods', - self.DEFAULT_ALLOWED_METHODS) + try: + allowed_methods = self._find_attr(func, 'allowed_methods') + except AttributeError: + allowed_methods = self.DEFAULT_ALLOWED_METHODS if request.method not in allowed_methods: allow_header = {'Allow': ', '.join(allowed_methods)} if request.method == 'OPTIONS':