Added further error checking, and the ability for view to provide raw errors instead of exceptions

This commit is contained in:
2010-06-01 11:30:34 +01:00
parent f3caf2a570
commit 9ab1e03138
2 changed files with 8 additions and 5 deletions

View File

@@ -23,14 +23,18 @@ def retrieve_xml(request):
if url_path == '/' or url_path == '':
# If they don't provide any kind of query, shoot a quick error message.
return HttpResponse('No API query specified.')
return HttpResponseNotFound('No API query specified.')
if 'userID' in params and not 'service' in params:
return HttpResponse('No Service ID provided.')
# The query system will retrieve a cached_doc that was either previously
# or newly cached depending on cache intervals.
cached_doc = CachedDocument.objects.api_query(url_path, params)
try:
cached_doc = CachedDocument.objects.api_query(url_path, params, exceptions=False)
except:
return HttpResponseServerError()
# Return the document's body as XML.
if cached_doc: