8000 moved legacy check to compat.py, also future-proofed function. · flask-api/flask-api@4f3af90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f3af90

Browse files
author
Chris Dutra
committed
moved legacy check to compat.py, also future-proofed function.
1 parent 43796ba commit 4f3af90

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

flask_api/app.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from werkzeug.exceptions import HTTPException
1111
import re
1212
import sys
13-
from flask import __version__ as flask_version
13+
from compat import is_flask_legacy
1414

1515

1616
api_resources = Blueprint(
@@ -89,8 +89,7 @@ def handle_user_exception(self, e):
8989
if handlers is not None:
9090
blueprint_handlers = handlers.get(None, ())
9191
app_handlers = self.error_handler_spec[None].get(None, ())
92-
flask_version.split()
93-
if self.get_minor_version() <= 10:
92+
if is_flask_legacy():
9493
for typecheck, handler in chain(blueprint_handlers, app_handlers):
9594
if isinstance(e, typecheck):
9695
return handler(e)
@@ -123,7 +122,3 @@ def create_url_adapter(self, request):
123122
self.config['SERVER_NAME'],
124123
script_name=self.config['APPLICATION_ROOT'] or '/',
125124
url_scheme=self.config['PREFERRED_URL_SCHEME'])
126-
127-
@staticmethod
128-
def get_minor_version():
129-
return int(flask_version.split(".")[1])

flask_api/compat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals, absolute_import
3+
from flask import __version__ as flask_version
34

45
# Markdown is optional
56
try:
@@ -16,5 +17,11 @@ def apply_markdown(text):
1617
md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode)
1718
return md.convert(text)
1819

20+
1921
except ImportError:
2022
apply_markdown = None
23+
24+
25+
def is_flask_legacy():
26+
v = flask_version.split(".")
27+
return int(v[0]) == 0 and int(v[1]) < 11

0 commit comments

Comments
 (0)
0