Skip to content

Commit

Permalink
controller.api minor code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 28, 2012
1 parent c6834aa commit 10f9ec4
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions ckan/controllers/api.py
Expand Up @@ -96,35 +96,27 @@ def _finish_ok(self, response_data=None,
'''
if resource_location:
status_int = 201
self._set_response_header('Location',
resource_location)
self._set_response_header('Location', resource_location)
else:
status_int = 200

return self._finish(status_int, response_data,
content_type=content_type)
return self._finish(status_int, response_data, content_type)

def _finish_not_authz(self):
response_data = _('Access denied')
return self._finish(status_int=403,
response_data=response_data,
content_type='json')
return self._finish(403, response_data, 'json')

def _finish_not_found(self, extra_msg=None):
response_data = _('Not found')
if extra_msg:
response_data = '%s - %s' % (response_data, extra_msg)
return self._finish(status_int=404,
response_data=response_data,
content_type='json')
return self._finish(404, response_data, 'json')

def _finish_bad_request(self, extra_msg=None):
response_data = _('Bad request')
if extra_msg:
response_data = '%s - %s' % (response_data, extra_msg)
return self._finish(status_int=400,
response_data=response_data,
content_type='json')
return self._finish(400, response_data, 'json')

def _wrap_jsonp(self, callback, response_msg):
return '%s(%s);' % (callback, response_msg)
Expand Down

0 comments on commit 10f9ec4

Please sign in to comment.