server/sources/datafeed.py
branchstable
changeset 8547 f23ac525ddd1
parent 8529 1daea1f433c9
child 8573 ae0a567dff30
--- a/server/sources/datafeed.py	Mon Sep 10 15:17:10 2012 +0200
+++ b/server/sources/datafeed.py	Thu Sep 13 17:26:15 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.set_attributes(**attrs)
                 self.notify_updated(entity)
 
+
 class DataFeedXMLParser(DataFeedParser):
 
     def process(self, url, raise_on_error=False):