[datafeed] give an error message if a source is missing a parser id
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 05 Mar 2014 13:51:28 +0100
changeset 10454 20f45a9b385c
parent 10453 76f601a90aa7
child 10455 ad0615d4500d
[datafeed] give an error message if a source is missing a parser id Closes #3484231
server/sources/datafeed.py
--- a/server/sources/datafeed.py	Mon Jun 23 16:54:35 2014 +0200
+++ b/server/sources/datafeed.py	Wed Mar 05 13:51:28 2014 +0100
@@ -127,6 +127,9 @@
         self.load_mapping(source_entity._cw)
 
     def _get_parser(self, cnx, **kwargs):
+        if self.parser_id is None:
+            self.warning('No parser defined on source %r', self)
+            raise ObjectNotFound()
         return self.repo.vreg['parsers'].select(
             self.parser_id, cnx, source=self, **kwargs)
 
@@ -201,7 +204,10 @@
     def _pull_data(self, cnx, force=False, raise_on_error=False):
         importlog = self.init_import_log(cnx)
         myuris = self.source_cwuris(cnx)
-        parser = self._get_parser(cnx, sourceuris=myuris, import_log=importlog)
+        try:
+            parser = self._get_parser(cnx, sourceuris=myuris, import_log=importlog)
+        except ObjectNotFound:
+            return {}
         if self.process_urls(parser, self.urls, raise_on_error):
             self.warning("some error occurred, don't attempt to delete entities")
         else: