Browse Source

fix metaclass usage for py3

pull/744/head
Thomas Waldmann 11 years ago
parent
commit
83f7658572
  1. 5
      flask/views.py

5
flask/views.py

@ -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…
Cancel
Save