server/sources/datafeed.py
changeset 7399 972ed1843bd8
parent 7398 26695dd703d8
child 7444 9bb8f89fd31c
--- a/server/sources/datafeed.py	Thu May 19 10:53:11 2011 +0200
+++ b/server/sources/datafeed.py	Thu May 19 10:53:17 2011 +0200
@@ -27,7 +27,7 @@
 
 from lxml import etree
 
-from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError
+from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError, UnknownEid
 from cubicweb.server.sources import AbstractSource
 from cubicweb.appobject import AppObject
 
@@ -218,9 +218,23 @@
         raise ValidationError(schemacfg.eid, {None: msg})
 
     def extid2entity(self, uri, etype, **sourceparams):
+        """return an entity for the given uri. May return None if it should be
+        skipped
+        """
         sourceparams['parser'] = self
         eid = self.source.extid2eid(str(uri), etype, self._cw,
                                     sourceparams=sourceparams)
+        if eid < 0:
+            # entity has been moved away from its original source
+            #
+            # Don't give etype to entity_from_eid so we get UnknownEid if the
+            # entity has been removed
+            try:
+                entity = self._cw.entity_from_eid(-eid)
+            except UnknownEid:
+                return None
+            self.notify_updated(entity) # avoid later update from the source's data
+            return entity
         if self.sourceuris is not None:
             self.sourceuris.pop(str(uri), None)
         return self._cw.entity_from_eid(eid, etype)