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
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
added flask 0.10 support to fix testing bug.
  • Loading branch information
Chris Dutra committed Jul 19, 2016
commit 43796ba0bb294ea09cdfeb45545a4e9e9f91bb34
17 changes: 14 additions & 3 deletions flask_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from werkzeug.exceptions import HTTPException
import re
import sys
from flask import __version__ as flask_version


api_resources = Blueprint(
Expand Down Expand Up @@ -88,9 +89,15 @@ 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, ())
for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()):
if isinstance(e, typecheck):
return handler(e)
flask_version.split()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this line has any affect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will amend.

if self.get_minor_version() <= 10:
for typecheck, handler in chain(blueprint_handlers, app_handlers):
if isinstance(e, typecheck):
return handler(e)
else:
for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()):
if isinstance(e, typecheck):
return handler(e)

reraise(exc_type, exc_value, tb)

Expand All @@ -116,3 +123,7 @@ 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():
Copy link
Member
@jacebrowning jacebrowning Jul 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this function might make more sense to live in compat.py and be reworked to something like is_flask_0_10()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, can do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is_flask_10 or is_flask_legacy. Whatever makes most sense to you.

return int(flask_version.split(".")[1])
0