From 4629d643611872b3232fb12e7d45584a58bc1223 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 21 Feb 2012 03:29:51 +0530 Subject: [PATCH] avoid DoesNotExist errors while updating matches --- pandora/annotation/tasks.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index b7246ba8..4ecf126b 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -21,11 +21,14 @@ def update_matching_events(id): e.update_matches() ids = [e['id'] for e in Event.objects.all().values('id')] for i in ids: - e = Event.objects.get(pk=i) - for name in [e.name] + list(e.alternativeNames): - if name.lower() in a.value.lower(): - e.update_matches() - break + try: + e = Event.objects.get(pk=i) + for name in [e.name] + list(e.alternativeNames): + if name.lower() in a.value.lower(): + e.update_matches() + break + except Event.DoesNotExist: + pass @task(ignore_resulsts=True, queue='default') def update_matching_places(id): @@ -42,11 +45,14 @@ def update_matching_places(id): p.update_matches() ids = [e['id'] for e in Place.objects.all().values('id')] for i in ids: - e = Place.objects.get(pk=i) - for name in [e.name] + list(e.alternativeNames): - if name.lower() in a.value.lower(): - e.update_matches() - break + try: + e = Place.objects.get(pk=i) + for name in [e.name] + list(e.alternativeNames): + if name.lower() in a.value.lower(): + e.update_matches() + break + except Place.DoesNotExist: + pass @task(ignore_resulsts=True, queue='default') def update_item(id):