8000 fix for #58 by dutronlabs · Pull Request #59 · flask-api/flask-api · GitHub
[go: up one dir, main page]

Skip to content

fix for #58 #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moved legacy check to compat.py, also future-proofed function.
  • Loading branch information
Chris Dutra committed Jul 19, 2016
commit 4f3af90d434689e45b95a43109d73e2109bbffa1
9 changes: 2 additions & 7 deletions flask_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from werkzeug.exceptions import HTTPException
import re
import sys
from flask import __version__ as flask_version
from compat import is_flask_legacy


api_resources = Blueprint(
Expand Down Expand Up @@ -89,8 +89,7 @@ def handle_user_exception(self, e):
if handlers is not None:
blueprint_handlers = handlers.get(None, ())
app_handlers = self.error_handler_spec[None].get(None, ())
flask_version.split()
if self.get_minor_version() <= 10:
if is_flask_legacy():
for typecheck, handler in chain(blueprint_handlers, app_handlers):
if isinstance(e, typecheck):
return handler(e)
Expand Down Expand Up @@ -123,7 +122,3 @@ def create_url_adapter(self, request):
self.config['SERVER_NAME'],
script_name=self.config['APPLICATION_ROOT'] or '/',
url_scheme=self.config['PREFERRED_URL_SCHEME'])

@staticmethod
def get_minor_version():
return int(flask_version.split(".")[1])
7 changes: 7 additions & 0 deletions flask_api/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from flask import __version__ as flask_version

# Markdown is optional
try:
Expand All @@ -16,5 +17,11 @@ def apply_markdown(text):
md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode)
return md.convert(text)


except ImportError:
apply_markdown = None


def is_flask_legacy():
v = flask_version.split(".")
return int(v[0]) == 0 and int(v[1]) < 11
0