provide local_add_relation / add_relation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 08 Jun 2009 20:34:28 +0200
branchstable
changeset 2062 20f18837107c
parent 2061 6a5044f15cb9
child 2063 fe4278b50388
provide local_add_relation / add_relation
server/sources/extlite.py
--- a/server/sources/extlite.py	Mon Jun 08 18:32:23 2009 +0200
+++ b/server/sources/extlite.py	Mon Jun 08 20:34:28 2009 +0200
@@ -214,6 +214,22 @@
         sql = self.sqladapter.sqlgen.delete(SQL_PREFIX + etype, attrs)
         sqlcursor.execute(sql, attrs)
 
+    def local_add_relation(self, session, subject, rtype, object):
+        """add a relation to the source
+
+        This is not provided as add_relation implementation since usually
+        source don't want to simply do this, so let raise NotImplementedError
+        and the source implementor may use this method if necessary
+        """
+        sqlcursor = session.pool[self.uri]
+        attrs = {'eid_from': subject, 'eid_to': object}
+        sql = self.sqladapter.sqlgen.insert('%s_relation' % rtype, attrs)
+        sqlcursor.execute(sql, attrs)
+
+    def add_relation(self, session, subject, rtype, object):
+        """add a relation to the source"""
+        raise NotImplementedError()
+
     def delete_relation(self, session, subject, rtype, object):
         """delete a relation from the source"""
         rschema = self.schema.rschema(rtype)