Mercurial > kallithea
comparison rhodecode/controllers/api/__init__.py @ 1508:4aba7be311e8 beta
API added checks for a valid repository on pull command
Added pre-check if repository have a remote_uri defines before pulling
bugfix with no default arguments on api function
added traceback when unhandled exception occurs on API
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 02 Oct 2011 02:06:23 +0200 |
parents | ed3254ac279b |
children | 87ec80c280bb |
comparison
equal
deleted
inserted
replaced
1507:7d687ed11929 | 1508:4aba7be311e8 |
---|---|
28 import inspect | 28 import inspect |
29 import json | 29 import json |
30 import logging | 30 import logging |
31 import types | 31 import types |
32 import urllib | 32 import urllib |
33 import traceback | |
33 from itertools import izip_longest | 34 from itertools import izip_longest |
34 | 35 |
35 from paste.response import replace_header | 36 from paste.response import replace_header |
36 | 37 |
37 from pylons.controllers import WSGIController | 38 from pylons.controllers import WSGIController |
133 | 134 |
134 # now that we have a method, add self._req_params to | 135 # now that we have a method, add self._req_params to |
135 # self.kargs and dispatch control to WGIController | 136 # self.kargs and dispatch control to WGIController |
136 argspec = inspect.getargspec(self._func) | 137 argspec = inspect.getargspec(self._func) |
137 arglist = argspec[0][1:] | 138 arglist = argspec[0][1:] |
138 defaults = argspec[3] | 139 defaults = argspec[3] or [] |
139 default_empty = types.NotImplementedType | 140 default_empty = types.NotImplementedType |
141 | |
140 kwarglist = list(izip_longest(reversed(arglist),reversed(defaults), | 142 kwarglist = list(izip_longest(reversed(arglist),reversed(defaults), |
141 fillvalue=default_empty)) | 143 fillvalue=default_empty)) |
142 | 144 |
143 # this is little trick to inject logged in user for | 145 # this is little trick to inject logged in user for |
144 # perms decorators to work they expect the controller class to have | 146 # perms decorators to work they expect the controller class to have |
200 if isinstance(raw_response, HTTPError): | 202 if isinstance(raw_response, HTTPError): |
201 self._error = str(raw_response) | 203 self._error = str(raw_response) |
202 except JSONRPCError as e: | 204 except JSONRPCError as e: |
203 self._error = str(e) | 205 self._error = str(e) |
204 except Exception as e: | 206 except Exception as e: |
205 log.debug('Encountered unhandled exception: %s', repr(e)) | 207 log.error('Encountered unhandled exception: %s' % traceback.format_exc()) |
206 json_exc = JSONRPCError('Internal server error') | 208 json_exc = JSONRPCError('Internal server error') |
207 self._error = str(json_exc) | 209 self._error = str(json_exc) |
208 | 210 |
209 if self._error is not None: | 211 if self._error is not None: |
210 raw_response = None | 212 raw_response = None |