From 1069b3a88deebd8f3988daf355e8c20dd868ff2e Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Mon, 25 Nov 2013 09:12:51 +0100 Subject: [PATCH] Simplificiation of a snippet GET. No check for Multiple objects, if it really happens, fail loud. --- dpaste/views.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dpaste/views.py b/dpaste/views.py index 537e3c4..bbdcc92 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -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)