Commit ca7c634b authored by Samuel Trégouët's avatar Samuel Trégouët
Browse files

make it works with pyramid 1.5.1

- predicates should be imported from pyramid.config
- httpexception with some body should be json formatted string

--HG--
branch : 0.1
parent 3173d0fb637b
......@@ -19,7 +19,7 @@ __depends__ = {
'six': '>= 1.4.0',
'jsonschema': None,
'jsl': None,
'pyramid': '>= 1.8.0',
'pyramid': '>= 1.5.0',
}
__recommends__ = {}
......
......@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-jsonschema Pyramid views for the JSON API of entities."""
import json
from pyramid import httpexceptions
from pyramid.renderers import render
......@@ -342,6 +343,9 @@ def generic_error(exc, request):
# be catched, including the standard pyramid return exceptions.
# In this case, just return it
if isinstance(exc, httpexceptions.HTTPException):
if exc.content_type != 'application/json':
exc.content_type = 'application/json'
exc.body = json.dumps({'message': exc.detail})
return exc
request.cw_cnx.rollback()
LOG.exception('exception occurred while processing %s', request)
......
......@@ -16,7 +16,7 @@
"""cubicweb-jsonschema predicates"""
from pyramid import predicates
from pyramid.config import predicates
class NoWildcardAcceptPredicate(predicates.AcceptPredicate):
......
......@@ -15,7 +15,7 @@ Architecture: all
Depends:
python-cubicweb-pyramid (>= 3.24.1),
python-six (>= 1.4.0),
python-pyramid (>= 1.8.0),
python-pyramid (>= 1.5.0),
${python:Depends},
${misc:Depends},
Description: JSON Schema for CubicWeb
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment