forked from orbit-oss/flask
fix metaclass usage for py3
This commit is contained in:
parent
af5576a6c5
commit
83f7658572
1 changed files with 2 additions and 3 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
from .globals import request
|
from .globals import request
|
||||||
|
from ._compat import with_metaclass
|
||||||
|
|
||||||
|
|
||||||
http_method_funcs = frozenset(['get', 'post', 'head', 'options',
|
http_method_funcs = frozenset(['get', 'post', 'head', 'options',
|
||||||
|
|
@ -119,7 +120,7 @@ class MethodViewType(type):
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
class MethodView(View):
|
class MethodView(with_metaclass(MethodViewType, View)):
|
||||||
"""Like a regular class-based view but that dispatches requests to
|
"""Like a regular class-based view but that dispatches requests to
|
||||||
particular methods. For instance if you implement a method called
|
particular methods. For instance if you implement a method called
|
||||||
:meth:`get` it means you will response to ``'GET'`` requests and
|
:meth:`get` it means you will response to ``'GET'`` requests and
|
||||||
|
|
@ -138,8 +139,6 @@ class MethodView(View):
|
||||||
|
|
||||||
app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
|
app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
|
||||||
"""
|
"""
|
||||||
__metaclass__ = MethodViewType
|
|
||||||
|
|
||||||
def dispatch_request(self, *args, **kwargs):
|
def dispatch_request(self, *args, **kwargs):
|
||||||
meth = getattr(self, request.method.lower(), None)
|
meth = getattr(self, request.method.lower(), None)
|
||||||
# if the request method is HEAD and we don't have a handler for it
|
# if the request method is HEAD and we don't have a handler for it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue