8000 added flask 0.10 support to fix testing bug. · flask-api/flask-api@43796ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 43796ba

Browse files
author
Chris Dutra
committed
added flask 0.10 support to fix testing bug.
1 parent fb5e5bb commit 43796ba

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

flask_api/app.py

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

1415

1516
api_resources = Blueprint(
@@ -88,9 +89,15 @@ def handle_user_exception(self, e):
8889
if handlers is not None:
8990
blueprint_handlers = handlers.get(None, ())
9091
app_handlers = self.error_handler_spec[None].get(None, ())
91-
for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()):
92-
if isinstance(e, typecheck):
93-
return handler(e)
92+
flask_version.split()
93+
if self.get_minor_version() <= 10:
94+
for typecheck, handler in chain(blueprint_handlers, app_handlers):
95+
if isinstance(e, typecheck):
96+
return handler(e)
97+
else:
98+
for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()):
99+
if isinstance(e, typecheck):
100+
return handler(e)
94101

95102
reraise(exc_type, exc_value, tb)
96103

@@ -116,3 +123,7 @@ def create_url_adapter(self, request):
116123
self.config['SERVER_NAME'],
117124
script_name=self.config['APPLICATION_ROOT'] or '/',
118125
url_scheme=self.config['PREFERRED_URL_SCHEME'])
126+
127+
@staticmethod
128+
def get_minor_version():
129+
return int(flask_version.split(".")[1])

0 commit comments

Comments
 (0)
0