server/sources/datafeed.py
changeset 8573 ae0a567dff30
parent 8535 268b6349baf3
parent 8547 f23ac525ddd1
child 8674 001c1592060a
--- a/server/sources/datafeed.py	Fri Oct 12 15:38:58 2012 +0200
+++ b/server/sources/datafeed.py	Fri Oct 12 16:05:16 2012 +0200
@@ -30,6 +30,7 @@
 from lxml import etree
 
 from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError, UnknownEid
+from cubicweb.server.repository import preprocess_inlined_relations
 from cubicweb.server.sources import AbstractSource
 from cubicweb.appobject import AppObject
 
@@ -254,11 +255,20 @@
         """called by the repository after an entity stored here has been
         inserted in the system table.
         """
+        relations = preprocess_inlined_relations(session, entity)
         if session.is_hook_category_activated('integrity'):
             entity.cw_edited.check(creation=True)
         self.repo.system_source.add_entity(session, entity)
         entity.cw_edited.saved = entity._cw_is_saved = True
         sourceparams['parser'].after_entity_copy(entity, sourceparams)
+        # call hooks for inlined relations
+        call_hooks = self.repo.hm.call_hooks
+        if self.should_call_hooks:
+            for attr, value in relations:
+                call_hooks('before_add_relation', session,
+                           eidfrom=entity.eid, rtype=attr, eidto=value)
+                call_hooks('after_add_relation', session,
+                           eidfrom=entity.eid, rtype=attr, eidto=value)
 
     def source_cwuris(self, session):
         sql = ('SELECT extid, eid, type FROM entities, cw_source_relation '
@@ -399,6 +409,7 @@
                 entity.cw_set(**attrs)
                 self.notify_updated(entity)
 
+
 class DataFeedXMLParser(DataFeedParser):
 
     def process(self, url, raise_on_error=False):