Add the ability to combine MethodViews

This commit is contained in:
Antoine Catton 2016-06-28 17:20:25 +02:00
parent 67e391921c
commit 516ce59f95
2 changed files with 47 additions and 1 deletions

View file

@ -102,12 +102,16 @@ class View(object):
return view
def get_methods(cls):
return getattr(cls, 'methods', []) or []
class MethodViewType(type):
def __new__(cls, name, bases, d):
rv = type.__new__(cls, name, bases, d)
if 'methods' not in d:
methods = set(rv.methods or [])
methods = set(m for b in bases for m in get_methods(b))
for key in d:
if key in http_method_funcs:
methods.add(key.upper())