forked from orbit-oss/flask
Merge pull request #744 from ThomasWaldmann/sprint-branch
2 small fixes for metaclass and import usage
This commit is contained in:
commit
1fe20d3208
7 changed files with 8 additions and 9 deletions
|
|
@ -34,7 +34,7 @@ from .templating import DispatchingJinjaLoader, Environment, \
|
||||||
_default_template_ctx_processor
|
_default_template_ctx_processor
|
||||||
from .signals import request_started, request_finished, got_request_exception, \
|
from .signals import request_started, request_finished, got_request_exception, \
|
||||||
request_tearing_down, appcontext_tearing_down
|
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
|
# a lock used for logger initialization
|
||||||
_logger_lock = Lock()
|
_logger_lock = Lock()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import os
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
from werkzeug.utils import import_string
|
from werkzeug.utils import import_string
|
||||||
from flask._compat import string_types
|
from ._compat import string_types
|
||||||
|
|
||||||
|
|
||||||
class ConfigAttribute(object):
|
class ConfigAttribute(object):
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
:copyright: (c) 2011 by Armin Ronacher.
|
:copyright: (c) 2011 by Armin Ronacher.
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
from flask._compat import implements_to_string
|
from ._compat import implements_to_string
|
||||||
|
|
||||||
|
|
||||||
class UnexpectedUnicodeError(AssertionError, UnicodeError):
|
class UnexpectedUnicodeError(AssertionError, UnicodeError):
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from flask._compat import reraise
|
from ._compat import reraise
|
||||||
|
|
||||||
|
|
||||||
class ExtensionImporter(object):
|
class ExtensionImporter(object):
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ from functools import update_wrapper
|
||||||
|
|
||||||
from werkzeug.datastructures import Headers
|
from werkzeug.datastructures import Headers
|
||||||
from werkzeug.exceptions import NotFound
|
from werkzeug.exceptions import NotFound
|
||||||
from flask._compat import string_types, text_type
|
|
||||||
|
|
||||||
# this was moved in 0.7
|
# this was moved in 0.7
|
||||||
try:
|
try:
|
||||||
|
|
@ -37,6 +36,7 @@ from jinja2 import FileSystemLoader
|
||||||
from .signals import message_flashed
|
from .signals import message_flashed
|
||||||
from .globals import session, _request_ctx_stack, _app_ctx_stack, \
|
from .globals import session, _request_ctx_stack, _app_ctx_stack, \
|
||||||
current_app, request
|
current_app, request
|
||||||
|
from ._compat import string_types, text_type
|
||||||
|
|
||||||
|
|
||||||
# sentinel
|
# sentinel
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from werkzeug.test import Client, EnvironBuilder
|
from werkzeug.test import Client, EnvironBuilder
|
||||||
from flask import _request_ctx_stack
|
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):
|
def make_test_environ_builder(app, path='/', base_url=None, *args, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -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