# HG changeset patch # User Sylvain Thénault # Date 1249076307 -7200 # Node ID 5196d213f4e3ac3dcf89738da7a46309717a8b12 # Parent 6cd6c5d11b45c09b909269f56b5c8cce279aa694 [R querier] new READ_ONLY_RTYPES constant diff -r 6cd6c5d11b45 -r 5196d213f4e3 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)]