cubicweb/server/repository.py
changeset 11962 36851c8b6763
parent 11950 68766861debe
child 11975 248039d0e6b1
equal deleted inserted replaced
11960:36f463441764 11962:36851c8b6763
    42 from yams import BadSchemaDefinition
    42 from yams import BadSchemaDefinition
    43 from rql.utils import rqlvar_maker
    43 from rql.utils import rqlvar_maker
    44 
    44 
    45 from cubicweb import (CW_MIGRATION_MAP, QueryError,
    45 from cubicweb import (CW_MIGRATION_MAP, QueryError,
    46                       UnknownEid, AuthenticationError, ExecutionError,
    46                       UnknownEid, AuthenticationError, ExecutionError,
    47                       BadConnectionId, ValidationError, Unauthorized,
    47                       BadConnectionId,
    48                       UniqueTogetherError, onevent, ViolatedConstraint)
    48                       UniqueTogetherError, onevent, ViolatedConstraint)
    49 from cubicweb import set_log_methods
    49 from cubicweb import set_log_methods
    50 from cubicweb import cwvreg, schema, server
    50 from cubicweb import cwvreg, schema, server
    51 from cubicweb.server import ShuttingDown, utils, hook, querier, sources
    51 from cubicweb.server import ShuttingDown, utils, hook, querier, sources
    52 from cubicweb.server.session import Session, InternalManager
    52 from cubicweb.server.session import Session, InternalManager
   821                         # don't skip inlined relation so they are regularly
   821                         # don't skip inlined relation so they are regularly
   822                         # deleted and so hooks are correctly called
   822                         # deleted and so hooks are correctly called
   823                         rql = 'DELETE X %s Y WHERE X eid IN (%s)' % (rtype, in_eids)
   823                         rql = 'DELETE X %s Y WHERE X eid IN (%s)' % (rtype, in_eids)
   824                     else:
   824                     else:
   825                         rql = 'DELETE Y %s X WHERE X eid IN (%s)' % (rtype, in_eids)
   825                         rql = 'DELETE Y %s X WHERE X eid IN (%s)' % (rtype, in_eids)
   826                     try:
   826                     cnx.execute(rql, build_descr=False)
   827                         cnx.execute(rql, build_descr=False)
       
   828                     except ValidationError:
       
   829                         raise
       
   830                     except Unauthorized:
       
   831                         self.exception(
       
   832                             'Unauthorized exception while cascading delete for entity %s. '
       
   833                             'RQL: %s.\nThis should not happen since security is disabled here.',
       
   834                             entities, rql)
       
   835                         raise
       
   836                     except Exception:
       
   837                         if self.config.mode == 'test':
       
   838                             raise
       
   839                         self.exception('error while cascading delete for entity %s. RQL: %s',
       
   840                                        entities, rql)
       
   841 
   827 
   842     def init_entity_caches(self, cnx, entity, source):
   828     def init_entity_caches(self, cnx, entity, source):
   843         """Add entity to connection entities cache and repo's cache."""
   829         """Add entity to connection entities cache and repo's cache."""
   844         cnx.set_entity_cache(entity)
   830         cnx.set_entity_cache(entity)
   845         self._type_cache[entity.eid] = entity.cw_etype
   831         self._type_cache[entity.eid] = entity.cw_etype