fix w/ local roles
authorsylvain.thenault@logilab.fr
Tue, 13 Jan 2009 17:57:19 +0100
changeset 394 1cc99ab21304
parent 393 45a675515427
child 395 cce260264122
fix w/ local roles
common/selectors.py
--- a/common/selectors.py	Tue Jan 13 17:56:02 2009 +0100
+++ b/common/selectors.py	Tue Jan 13 17:57:19 2009 +0100
@@ -410,7 +410,8 @@
         if not (eschema.has_perm(req, perm) or eschema.has_local_role(perm)):
             return 0
     if hasattr(cls, 'rtype'):
-        if not schema.rschema(cls.rtype).has_perm(req, perm):
+        rschema = schema.rschema(cls.rtype)
+        if not (rschema.has_perm(req, perm) or rschema.has_local_role(perm)):
             return 0
     return 1
 
@@ -421,8 +422,9 @@
     result set has this relation.
     """
     if hasattr(cls, 'rtype'):
+        rschema = cls.schema.rschema(cls.rtype)
         perm = getattr(cls, 'require_permission', 'read')
-        if not cls.schema.rschema(cls.rtype).has_perm(req, perm):
+        if not (rschema.has_perm(req, perm) or rschema.has_local_role(perm)):
             return 0
         if row is None:
             for etype in rset.column_types(col or 0):
@@ -439,8 +441,9 @@
     .rtype attribute of the class, and if at least one entity type in the
     result set has this relation.
     """
+    rschema = cls.schema.rschema(cls.rtype)
     perm = getattr(cls, 'require_permission', 'read')
-    if not cls.schema.rschema(cls.rtype).has_perm(req, perm):
+    if not (rschema.has_perm(req, perm) or rschema.has_local_role(perm)):
         return 0
     if row is None:
         for etype in rset.column_types(col or 0):