|
@@ -5,6 +5,8 @@ import time
|
5
|
5
|
from pyramid.config import Configurator
|
6
|
6
|
from pyramid.authentication import BasicAuthAuthenticationPolicy
|
7
|
7
|
from hapic.ext.pyramid import PyramidContext
|
|
8
|
+from pyramid.exceptions import NotFound
|
|
9
|
+from sqlalchemy.exc import OperationalError
|
8
|
10
|
|
9
|
11
|
from tracim.extensions import hapic
|
10
|
12
|
from tracim.config import CFG
|
|
@@ -52,12 +54,15 @@ def web(global_config, **local_settings):
|
52
|
54
|
# Add SqlAlchemy DB
|
53
|
55
|
configurator.include('.models')
|
54
|
56
|
# set Hapic
|
55
|
|
- hapic.set_context(
|
56
|
|
- PyramidContext(
|
57
|
|
- configurator=configurator,
|
58
|
|
- default_error_builder=ErrorSchema()
|
59
|
|
- )
|
|
57
|
+ context = PyramidContext(
|
|
58
|
+ configurator=configurator,
|
|
59
|
+ default_error_builder=ErrorSchema(),
|
|
60
|
+ debug=app_config.DEBUG,
|
60
|
61
|
)
|
|
62
|
+ hapic.set_context(context)
|
|
63
|
+ context.handle_exception(NotFound, 404)
|
|
64
|
+ context.handle_exception(OperationalError, 500)
|
|
65
|
+ context.handle_exception(Exception, 500)
|
61
|
66
|
# Add controllers
|
62
|
67
|
session_api = SessionController()
|
63
|
68
|
configurator.include(session_api.bind, route_prefix=BASE_API_V2)
|