Simplificiation of a snippet GET. No check for Multiple objects, if it really happens, fail loud.

This commit is contained in:
Martin Mahner 2013-11-25 09:12:51 +01:00
parent 715be017dd
commit 1069b3a88d

View file

@ -55,15 +55,7 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h
Details list view of a snippet. Handles the actual view, reply and
tree/diff view.
"""
try:
snippet = Snippet.objects.get(secret_id=snippet_id)
except MultipleObjectsReturned:
raise Http404('Multiple snippets exist for this slug. This should never '
'happen but its likely that you are a spam bot, so I dont '
'care.')
except ObjectDoesNotExist:
raise Http404('This snippet does not exist anymore. Its likely that its '
'lifetime is expired.')
snippet = get_object_or_404(Snippet, secret_id=snippet_id)
tree = snippet.get_root()
tree = tree.get_descendants(include_self=True)