diff --git a/flask/app.py b/flask/app.py index 77e4799c..84ef1013 100644 --- a/flask/app.py +++ b/flask/app.py @@ -34,7 +34,7 @@ from .templating import DispatchingJinjaLoader, Environment, \ _default_template_ctx_processor from .signals import request_started, request_finished, got_request_exception, \ request_tearing_down, appcontext_tearing_down -from flask._compat import reraise, string_types, integer_types +from ._compat import reraise, string_types, integer_types # a lock used for logger initialization _logger_lock = Lock() diff --git a/flask/config.py b/flask/config.py index 4d9ac23a..155afa2f 100644 --- a/flask/config.py +++ b/flask/config.py @@ -14,7 +14,7 @@ import os import errno from werkzeug.utils import import_string -from flask._compat import string_types +from ._compat import string_types class ConfigAttribute(object): diff --git a/flask/debughelpers.py b/flask/debughelpers.py index f3bac185..2f8510f9 100644 --- a/flask/debughelpers.py +++ b/flask/debughelpers.py @@ -8,7 +8,7 @@ :copyright: (c) 2011 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ -from flask._compat import implements_to_string +from ._compat import implements_to_string class UnexpectedUnicodeError(AssertionError, UnicodeError): diff --git a/flask/exthook.py b/flask/exthook.py index 89dac47b..d0d814c6 100644 --- a/flask/exthook.py +++ b/flask/exthook.py @@ -21,7 +21,7 @@ """ import sys import os -from flask._compat import reraise +from ._compat import reraise class ExtensionImporter(object): diff --git a/flask/helpers.py b/flask/helpers.py index 37d3bb49..49fd0278 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -24,7 +24,6 @@ from functools import update_wrapper from werkzeug.datastructures import Headers from werkzeug.exceptions import NotFound -from flask._compat import string_types, text_type # this was moved in 0.7 try: @@ -37,6 +36,7 @@ from jinja2 import FileSystemLoader from .signals import message_flashed from .globals import session, _request_ctx_stack, _app_ctx_stack, \ current_app, request +from ._compat import string_types, text_type # sentinel diff --git a/flask/testing.py b/flask/testing.py index ef116cf3..4c1f4550 100644 --- a/flask/testing.py +++ b/flask/testing.py @@ -13,7 +13,7 @@ from contextlib import contextmanager from werkzeug.test import Client, EnvironBuilder from flask import _request_ctx_stack -from flask._compat import urlparse +from ._compat import urlparse def make_test_environ_builder(app, path='/', base_url=None, *args, **kwargs): diff --git a/flask/views.py b/flask/views.py index 5192c1c1..b3b61b52 100644 --- a/flask/views.py +++ b/flask/views.py @@ -9,6 +9,7 @@ :license: BSD, see LICENSE for more details. """ from .globals import request +from ._compat import with_metaclass http_method_funcs = frozenset(['get', 'post', 'head', 'options', @@ -119,7 +120,7 @@ class MethodViewType(type): return rv -class MethodView(View): +class MethodView(with_metaclass(MethodViewType, View)): """Like a regular class-based view but that dispatches requests to particular methods. For instance if you implement a method called :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')) """ - __metaclass__ = MethodViewType - def dispatch_request(self, *args, **kwargs): meth = getattr(self, request.method.lower(), None) # if the request method is HEAD and we don't have a handler for it