Skip to content

Commit

Permalink
Fix a key error on Propagate Exceptions config
Browse files Browse the repository at this point in the history
Add a notice about incompatibility with Sanic v19.12
  • Loading branch information
ashleysommer committed Jan 31, 2020
1 parent 7581ecf commit 2023300
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{md,rst}]
trim_trailing_whitespace = false

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
[*.{js,py,md,rst}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
max_line_length = 120
max_line_length = 119
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ If you are familiar with Sanic, Sanic-RESTPlus should be easy to pick up.
It provides a coherent collection of decorators and tools to describe your API
and expose its documentation properly using `Swagger`_.

Important Notice
================

Sanic-RestPlus version 0.4.1 (and previous versions) **does not work** on Sanic 19.12+, see this bug here: https://github.com/ashleysommer/sanicpluginsframework/issues/15

A fix is coming, but in the meantime, please use RestPlus with Sanic v19.6.3 or v19.9.0.

Compatibility
=============
Expand Down
2 changes: 1 addition & 1 deletion requirements/install.pip
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ jsonschema
methodtools
sanic>=0.8.3
sanic-jinja2-spf>=0.7.5
sanic-plugins-framework>=0.8.2
sanic-plugins-framework>=0.8.2,<0.9.0
pytz
2 changes: 1 addition & 1 deletion sanic_restplus/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: latin-1 -*-
#
__version__ = '0.4.1'
__version__ = '0.4.1.post1'
__description__ = 'Fully featured framework for fast, easy and documented API development with Sanic'
20 changes: 9 additions & 11 deletions sanic_restplus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,19 +703,19 @@ def _has_fr_route(self, request):
route_endpoint_name = route_endpoint_name[len(plugin_name_prefix):]
return self.owns_endpoint(route_endpoint_name)


def handle_error(self, request, e):
'''
Error handler for the API transforms a raised exception into a Flask response,
"""
Error handler for the API transforms a raised exception into a Sanic response,
with the appropriate HTTP status code and body.
:param Exception e: the raised Exception object
'''
:param request: The Sanic Request object
:type request: sanic.request.Request
:param e: the raised Exception object
:type e: Exception
"""
context = restplus.get_context_from_spf(self.spf_reg)
app = context.app
#got_request_exception.send(app._get_current_object(), exception=e)
if not isinstance(e, SanicException) and app.config['PROPAGATE_EXCEPTIONS']:
if not isinstance(e, SanicException) and app.config.get('PROPAGATE_EXCEPTIONS', False):
exc_type, exc_value, tb = sys.exc_info()
if exc_value is e:
raise
Expand Down Expand Up @@ -827,10 +827,8 @@ def as_postman(self, urlvars=False, swagger=False):
'''
return PostmanCollectionV1(self, swagger=swagger).as_dict(urlvars=urlvars)

# TODO: Sanic, payload (as a property) cannot see the request.
#@property
def payload(self, request):
'''Store the input payload in the current request context'''
"""Default behaviour for payload() is just to return the request.json"""
return request.json

@property
Expand Down

0 comments on commit 2023300

Please sign in to comment.