[R querier] new READ_ONLY_RTYPES constant
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 31 Jul 2009 23:38:27 +0200
changeset 2601 5196d213f4e3
parent 2600 6cd6c5d11b45
child 2602 7bfa83772d90
[R querier] new READ_ONLY_RTYPES constant
server/querier.py
--- a/server/querier.py	Fri Jul 31 23:37:42 2009 +0200
+++ b/server/querier.py	Fri Jul 31 23:38:27 2009 +0200
@@ -24,6 +24,8 @@
 from cubicweb.server.rqlannotation import SQLGenAnnotator, set_qdata
 from cubicweb.server.ssplanner import add_types_restriction
 
+READ_ONLY_RTYPES = set(('eid', 'has_text', 'is', 'is_instance_of', 'identity'))
+
 def empty_rset(session, rql, args, rqlst=None):
     """build an empty result set object"""
     return ResultSet([], rql, args, rqlst=rqlst)
@@ -67,7 +69,7 @@
     if rqlst.where is not None:
         for rel in rqlst.where.iget_nodes(Relation):
             # XXX has_text may have specific perm ?
-            if rel.r_type in ('is', 'is_instance_of', 'has_text', 'identity', 'eid'):
+            if rel.r_type in READ_ONLY_RTYPES:
                 continue
             if not schema.rschema(rel.r_type).has_access(user, 'read'):
                 raise Unauthorized('read', rel.r_type)
@@ -371,7 +373,7 @@
         for relation in rqlst.main_relations:
             lhs, rhs = relation.get_variable_parts()
             rtype = relation.r_type
-            if rtype in ('eid', 'has_text', 'is', 'is_instance_of', 'identity'):
+            if rtype in READ_ONLY_RTYPES:
                 raise QueryError("can't assign to %s" % rtype)
             try:
                 edef = to_build[str(lhs)]