[server caching] should set cache before call to after_add_entity hooks
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 10 Aug 2009 18:00:50 +0200
changeset 2756 2c94606eefc0
parent 2755 e69a4077ffb4
child 2758 8a54f91a43e1
[server caching] should set cache before call to after_add_entity hooks
server/repository.py
--- a/server/repository.py	Mon Aug 10 16:02:14 2009 +0200
+++ b/server/repository.py	Mon Aug 10 18:00:50 2009 +0200
@@ -1030,6 +1030,9 @@
             if rtype in VIRTUAL_RTYPES:
                 continue
             entity.set_related_cache(rtype, 'object', session.empty_rset())
+        # set inline relation cache before call to after_add_entity
+        for attr, value in relations:
+            session.update_rel_cache_add(entity.eid, attr, value)
         # trigger after_add_entity after after_add_relation
         if source.should_call_hooks:
             self.hm.call_hooks('after_add_entity', etype, session, entity)
@@ -1037,7 +1040,6 @@
             for attr, value in relations:
                 self.hm.call_hooks('before_add_relation', attr, session,
                                     entity.eid, attr, value)
-                session.update_rel_cache_add(entity.eid, attr, value)
                 self.hm.call_hooks('after_add_relation', attr, session,
                                     entity.eid, attr, value)
         return entity.eid