[multi-sources] new may_cross_relation method on sources 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 27 Aug 2009 17:02:02 +0200
branch3.5
changeset 3041 782fa7566a22
parent 3040 e4dc22040f5f
child 3042 d2455badf7fb
[multi-sources] new may_cross_relation method on sources
server/sources/__init__.py
server/sources/native.py
--- a/server/sources/__init__.py	Thu Aug 27 17:01:32 2009 +0200
+++ b/server/sources/__init__.py	Thu Aug 27 17:02:02 2009 +0200
@@ -182,6 +182,19 @@
             return wsupport
         return True
 
+    def may_cross_relation(self, rtype):
+        """return True if the relation may be crossed among sources. Rules are:
+
+        * if this source support the relation, can't be crossed unless explicitly
+          specified in .cross_relations
+
+        * if this source doesn't support the relation, can be crossed unless
+          explicitly specified in .dont_cross_relations
+        """
+        if self.support_relation(rtype):
+            return rtype in self.cross_relations
+        return rtype not in self.dont_cross_relations
+
     def eid2extid(self, eid, session=None):
         return self.repo.eid2extid(self, eid, session)
 
--- a/server/sources/native.py	Thu Aug 27 17:01:32 2009 +0200
+++ b/server/sources/native.py	Thu Aug 27 17:02:02 2009 +0200
@@ -268,6 +268,9 @@
         # can't claim not supporting a relation
         return True #not rtype == 'content_for'
 
+    def may_cross_relation(self, rtype):
+        return True
+
     def authenticate(self, session, login, password):
         """return CWUser eid for the given login/password if this account is
         defined in this source, else raise `AuthenticationError`