From: olivier <> Date: Thu, 9 Apr 2009 16:27:54 +0000 (+0000) Subject: #67: properly return an oai error if record doesn't exist (django exception wasn... X-Git-Tag: 1.1~686 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d01cd90507cef6aa027735e2b61c9521698ef5bb;p=telemeta.git #67: properly return an oai error if record doesn't exist (django exception wasn't caught) --- diff --git a/telemeta/interop/oaidatasource.py b/telemeta/interop/oaidatasource.py index 81d433a2..f71f86ae 100644 --- a/telemeta/interop/oaidatasource.py +++ b/telemeta/interop/oaidatasource.py @@ -58,9 +58,15 @@ class TelemetaOAIDataSource(object): """Return a specific record""" type, id = id.split(':') if (type == 'collection'): - record = MediaCollection.objects.get(id=id) + try: + record = MediaCollection.objects.get(id=id) + except MediaCollection.DoesNotExist: + return None elif (type == 'item'): - record = MediaItem.objects.get(id=id) + try: + record = MediaItem.objects.get(id=id) + except MediaItem.DoesNotExist: + return None else: raise Exception("No such record type: %s" % type)