Show More
@@ -39,7 +39,7 from pylons.controllers.util import Resp | |||
|
39 | 39 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ |
|
40 | 40 | HTTPBadRequest, HTTPError |
|
41 | 41 | |
|
42 |
from rhodecode.model. |
|
|
42 | from rhodecode.model.db import User | |
|
43 | 43 | from rhodecode.lib.auth import AuthUser |
|
44 | 44 | |
|
45 | 45 | log = logging.getLogger('JSONRPC') |
@@ -85,10 +85,9 class JSONRPCController(WSGIController): | |||
|
85 | 85 | Parse the request body as JSON, look up the method on the |
|
86 | 86 | controller and if it exists, dispatch to it. |
|
87 | 87 | """ |
|
88 | ||
|
89 | 88 | if 'CONTENT_LENGTH' not in environ: |
|
90 | 89 | log.debug("No Content-Length") |
|
91 |
return jsonrpc_error( |
|
|
90 | return jsonrpc_error(message="No Content-Length in request") | |
|
92 | 91 | else: |
|
93 | 92 | length = environ['CONTENT_LENGTH'] or 0 |
|
94 | 93 | length = int(environ['CONTENT_LENGTH']) |
@@ -96,7 +95,7 class JSONRPCController(WSGIController): | |||
|
96 | 95 | |
|
97 | 96 | if length == 0: |
|
98 | 97 | log.debug("Content-Length is 0") |
|
99 |
return jsonrpc_error( |
|
|
98 | return jsonrpc_error(message="Content-Length is 0") | |
|
100 | 99 | |
|
101 | 100 | raw_body = environ['wsgi.input'].read(length) |
|
102 | 101 | |
@@ -104,12 +103,10 class JSONRPCController(WSGIController): | |||
|
104 | 103 | json_body = json.loads(urllib.unquote_plus(raw_body)) |
|
105 | 104 | except ValueError as e: |
|
106 | 105 | #catch JSON errors Here |
|
107 | return jsonrpc_error("JSON parse error ERR:%s RAW:%r" \ | |
|
106 | return jsonrpc_error(message="JSON parse error ERR:%s RAW:%r" \ | |
|
108 | 107 | % (e, urllib.unquote_plus(raw_body))) |
|
109 | 108 | |
|
110 | ||
|
111 | 109 | #check AUTH based on API KEY |
|
112 | ||
|
113 | 110 | try: |
|
114 | 111 | self._req_api_key = json_body['api_key'] |
|
115 | 112 | self._req_method = json_body['method'] |
@@ -131,7 +128,7 class JSONRPCController(WSGIController): | |||
|
131 | 128 | try: |
|
132 | 129 | self._func = self._find_method() |
|
133 | 130 | except AttributeError, e: |
|
134 | return jsonrpc_error(str(e)) | |
|
131 | return jsonrpc_error(message=str(e)) | |
|
135 | 132 | |
|
136 | 133 | # now that we have a method, add self._req_params to |
|
137 | 134 | # self.kargs and dispatch control to WGIController |
@@ -143,7 +140,7 class JSONRPCController(WSGIController): | |||
|
143 | 140 | self.rhodecode_user = auth_u |
|
144 | 141 | |
|
145 | 142 | if 'user' not in arglist: |
|
146 | return jsonrpc_error('This method [%s] does not support ' | |
|
143 | return jsonrpc_error(message='This method [%s] does not support ' | |
|
147 | 144 | 'authentication (missing user param)' % |
|
148 | 145 | self._func.__name__) |
|
149 | 146 | |
@@ -155,7 +152,7 class JSONRPCController(WSGIController): | |||
|
155 | 152 | continue |
|
156 | 153 | |
|
157 | 154 | if not self._req_params or arg not in self._req_params: |
|
158 | return jsonrpc_error('Missing %s arg in JSON DATA' % arg) | |
|
155 | return jsonrpc_error(message='Missing %s arg in JSON DATA' % arg) | |
|
159 | 156 | |
|
160 | 157 | self._rpc_args = dict(user=u) |
|
161 | 158 | self._rpc_args.update(self._req_params) |
General Comments 0
You need to be logged in to leave comments.
Login now