Skip to content

Commit

Permalink
Allow View methods customization
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 6, 2016
1 parent 59dc3da commit 54b3e7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,11 @@ def __repr__(self):

class View(AbstractView):

METHODS = set(hdrs.METH_ALL)

@asyncio.coroutine
def __iter__(self):
if self.request.method not in hdrs.METH_ALL:
if self.request.method not in self.METHODS:
self._raise_allowed_methods()
method = getattr(self, self.request.method.lower(), None)
if method is None:
Expand All @@ -667,7 +669,7 @@ def __await__(self):
return (yield from self.__iter__())

def _raise_allowed_methods(self):
allowed_methods = {m for m in hdrs.METH_ALL if hasattr(self, m)}
allowed_methods = {m for m in self.METHODS if hasattr(self, m)}
raise HTTPMethodNotAllowed(self.request.method, allowed_methods)


Expand Down

0 comments on commit 54b3e7c

Please sign in to comment.