[R repo session] add_relation method use in hooks
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 31 Jul 2009 23:45:07 +0200
changeset 2604 6b55a2a81fd8
parent 2603 e47d63351891
child 2605 c4f6a53884ec
[R repo session] add_relation method use in hooks
server/session.py
--- a/server/session.py	Fri Jul 31 23:44:16 2009 +0200
+++ b/server/session.py	Fri Jul 31 23:45:07 2009 +0200
@@ -73,6 +73,17 @@
     def __str__(self):
         return '<%ssession %s (%s 0x%x)>' % (self.cnxtype, self.user.login,
                                              self.id, id(self))
+
+    def add_relation(self, fromeid, rtype, toeid):
+        if self.is_super_session:
+            self.repo.glob_add_relation(self, fromeid, rtype, toeid)
+            return
+        self.is_super_session = True
+        try:
+            self.repo.glob_add_relation(self, fromeid, rtype, toeid)
+        finally:
+            self.is_super_session = False
+
     # resource accessors ######################################################
 
     def actual_session(self):