check for empty source in dc
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 30 Jan 2012 16:14:35 +0000 (17:14 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 30 Jan 2012 16:14:35 +0000 (17:14 +0100)
apps/search/index.py

index d63d3f8..993c7d7 100644 (file)
@@ -332,9 +332,10 @@ class Index(BaseIndex):
 
         # get published date
         source = book_info.source_name
 
         # get published date
         source = book_info.source_name
-        match = self.published_date_re.search(source)
-        if match is not None:
-            fields["published_date"] = Field("published_date", str(match.groups()[0]), Field.Store.YES, Field.Index.NOT_ANALYZED)
+        if hasattr(book_info, 'source_name'):
+            match = self.published_date_re.search(source)
+            if match is not None:
+                fields["published_date"] = Field("published_date", str(match.groups()[0]), Field.Store.YES, Field.Index.NOT_ANALYZED)
 
         return fields
 
 
         return fields