30 from rql import RQLSyntaxError |
30 from rql import RQLSyntaxError |
31 from rql.stmts import Union, Select |
31 from rql.stmts import Union, Select |
32 from rql.nodes import (Relation, VariableRef, Constant, SubQuery, Function, |
32 from rql.nodes import (Relation, VariableRef, Constant, SubQuery, Function, |
33 Exists, Not) |
33 Exists, Not) |
34 |
34 |
35 from cubicweb import Unauthorized, QueryError, UnknownEid, typed_eid |
35 from cubicweb import ValidationError, Unauthorized, QueryError, UnknownEid |
36 from cubicweb import server |
36 from cubicweb import server, typed_eid |
37 from cubicweb.rset import ResultSet |
37 from cubicweb.rset import ResultSet |
38 |
38 |
39 from cubicweb.server.utils import cleanup_solutions |
39 from cubicweb.server.utils import cleanup_solutions |
40 from cubicweb.server.rqlannotation import SQLGenAnnotator, set_qdata |
40 from cubicweb.server.rqlannotation import SQLGenAnnotator, set_qdata |
41 from cubicweb.server.ssplanner import READ_ONLY_RTYPES, add_types_restriction, EditedEntity |
41 from cubicweb.server.ssplanner import READ_ONLY_RTYPES, add_types_restriction, EditedEntity |
700 plan.cache_key = cachekey |
700 plan.cache_key = cachekey |
701 self._planner.build_plan(plan) |
701 self._planner.build_plan(plan) |
702 # execute the plan |
702 # execute the plan |
703 try: |
703 try: |
704 results = plan.execute() |
704 results = plan.execute() |
705 except Unauthorized: |
705 except (Unauthorized, ValidationError): |
706 # XXX this could be done in security's after_add_relation hooks |
706 # getting an Unauthorized/ValidationError exception means the |
707 # since it's actually realy only needed there (other relations |
707 # transaction must been rollbacked |
708 # security is done *before* actual changes, and add/update entity |
|
709 # security is done after changes but in an operation, and exception |
|
710 # generated in operation's events properly generate a rollback on |
|
711 # the session). Even though, this is done here for a better |
|
712 # consistency: getting an Unauthorized exception means the |
|
713 # transaction has been rollbacked |
|
714 # |
708 # |
715 # notes: |
709 # notes: |
716 # * we should not reset the pool here, since we don't want the |
710 # * we should not reset the pool here, since we don't want the |
717 # session to loose its pool during processing |
711 # session to loose its pool during processing |
718 # * don't rollback if we're in the commit process, will be handled |
712 # * don't rollback if we're in the commit process, will be handled |