# HG changeset patch # User Sylvain Thénault # Date 1252919337 -7200 # Node ID b27d19c0db1cd412e7ba9784049257b7992e4135 # Parent 77936fa67ae633c3f4302f3205c826135392faf0 [repo] take care of inlined relation in session.[add|delete]_relation diff -r 77936fa67ae6 -r b27d19c0db1c server/session.py --- a/server/session.py Mon Sep 14 10:15:11 2009 +0200 +++ b/server/session.py Mon Sep 14 11:08:57 2009 +0200 @@ -84,13 +84,13 @@ session._threaddata = self.actual_session()._threaddata return session - def _change_relation(self, cb, fromeid, rtype, toeid): + def _super_call(self, __cb, *args, **kwargs): if self.is_super_session: - cb(self, fromeid, rtype, toeid) + __cb(self, *args, **kwargs) return self.is_super_session = True try: - cb(self, fromeid, rtype, toeid) + __cb(self, *args, **kwargs) finally: self.is_super_session = False @@ -105,8 +105,15 @@ You may use this in hooks when you know both eids of the relation you want to add. """ - self._change_relation(self.repo.glob_add_relation, - fromeid, rtype, toeid) + if self.vreg.schema[rtype].inlined: + entity = self.entity_from_eid(fromeid) + entity[rtype] = toeid + self._super_call(self.repo.glob_update_entity, + entity, set((rtype,))) + else: + self._super_call(self.repo.glob_add_relation, + fromeid, rtype, toeid) + def delete_relation(self, fromeid, rtype, toeid): """provide direct access to the repository method to delete a relation. @@ -118,8 +125,14 @@ You may use this in hooks when you know both eids of the relation you want to delete. """ - self._change_relation(self.repo.glob_delete_relation, - fromeid, rtype, toeid) + if self.vreg.schema[rtype].inlined: + entity = self.entity_from_eid(fromeid) + entity[rtype] = None + self._super_call(self.repo.glob_update_entity, + entity, set((rtype,))) + else: + self._super_call(self.repo.glob_delete_relation, + fromeid, rtype, toeid) # relations cache handling #################################################