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.
master
Dustin C. Hatch 2015-02-19 20:37:39 -06:00
parent 922778ee4c
commit 230da47d5b
1 changed files with 4 additions and 2 deletions

View File

@ -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':