File tree Expand file tree Collapse file tree 6 files changed +32
-5
lines changed Expand file tree Collapse file tree 6 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ Response marshalling
7
7
8
8
9
9
Flask-RESTX provides an easy way to control what data you actually render in
10
- your response or expect as in input payload.
10
+ your response or expect as an input payload.
11
11
With the :mod: `~.fields ` module, you can use whatever objects (ORM
12
12
models/custom classes/etc.) you want in your resource.
13
13
:mod: `~.fields ` also lets you format and filter the response
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Multiple namespaces
16
16
17
17
There are many different ways to organize your Flask-RESTX app,
18
18
but here we'll describe one that scales pretty well with larger apps
19
- and maintains a nice level organization.
19
+ and maintains a nice level of organization.
20
20
21
21
Flask-RESTX provides a way to use almost the same pattern as Flask's `blueprint `.
22
22
The main idea is to split your app into reusable namespaces.
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
- __version__ = "0.2 .1.dev"
2
+ __version__ = "0.3 .1.dev"
3
3
__description__ = (
4
4
"Fully featured framework for fast, easy and documented API development with Flask"
5
5
)
Original file line number Diff line number Diff line change @@ -677,7 +677,7 @@ def handle_error(self, e):
677
677
if (
678
678
not isinstance (e , HTTPException )
679
679
and current_app .propagate_exceptions
680
- and not isinstance (e , tuple (self .error_handlers .keys ()))
680
+ and not isinstance (e , tuple (self ._own_and_child_error_handlers .keys ()))
681
681
):
682
682
683
683
exc_type , exc_value , tb = sys .exc_info ()
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " flask-restx" ,
3
- "version" : " 0.2 .1.dev" ,
3
+ "version" : " 0.3 .1.dev" ,
4
4
"description" : " Fully featured framework for fast, easy and documented API development with Flask" ,
5
5
"repository" : " python-restx/flask-restx" ,
6
6
"keywords" : [
Original file line number Diff line number Diff line change @@ -653,3 +653,30 @@ def handle_custom_exception(error):
653
653
"message" : "error" ,
654
654
"test" : "value" ,
655
655
}
656
+
657
+ def test_namespace_errorhandler_with_propagate_true (self , app , client ):
658
+ """Exceptions with errorhandler on a namespace should not be
659
+ returned to client, even if PROPAGATE_EXCEPTIONS is set."""
660
+ app .config ["PROPAGATE_EXCEPTIONS" ] = True
661
+ api = restx .Api (app )
662
+ namespace = restx .Namespace ('test_namespace' )
663
+ api .add_namespace (namespace )
664
+
665
+ @namespace .route ("/test/" , endpoint = "test" )
666
+ class TestResource (restx .Resource ):
667
+ def get (self ):
668
+ raise RuntimeError ("error" )
669
+
670
+ @namespace .errorhandler (RuntimeError )
671
+ def handle_custom_exception (error ):
672
+ return {"message" : str (error ), "test" : "value" }, 400
673
+
674
+ response = client .get ("/test_namespace/test/" )
675
+ assert response .status_code == 400
676
+ assert response .content_type == "application/json"
677
+
678
+ data = json .loads (response .data .decode ("utf8" ))
679
+ assert data == {
680
+ "message" : "error" ,
681
+ "test" : "value" ,
682
+ }
You can’t perform that action at this time.
0 commit comments