Changeset - fe5575f95850
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2011-11-08 16:13:46
marcin@python-works.com
API returns proper JSON response
1 file changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/api/__init__.py
Show inline comments
 
@@ -36,7 +36,7 @@ from rhodecode.lib.compat import izip_lo
 
from paste.response import replace_header
 

	
 
from pylons.controllers import WSGIController
 
from pylons.controllers.util import Response
 

	
 

	
 
from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
 
HTTPBadRequest, HTTPError
 
@@ -56,9 +56,15 @@ class JSONRPCError(BaseException):
 

	
 

	
 
def jsonrpc_error(message, code=None):
 
    """Generate a Response object with a JSON-RPC error body"""
 
    return Response(body=json.dumps(dict(result=None,
 
                                         error=message)))
 
    """
 
    Generate a Response object with a JSON-RPC error body
 
    """
 
    from pylons.controllers.util import Response
 
    resp = Response(body=json.dumps(dict(result=None, error=message)),
 
                    status=code,
 
                    content_type='application/json')
 
    return resp
 

	
 

	
 

	
 
class JSONRPCController(WSGIController):
0 comments (0 inline, 0 general)