1175 if scleanup is not None: |
1175 if scleanup is not None: |
1176 source = self.sources_by_eid[scleanup] |
1176 source = self.sources_by_eid[scleanup] |
1177 # delete remaining relations: if user can delete the entity, he can |
1177 # delete remaining relations: if user can delete the entity, he can |
1178 # delete all its relations without security checking |
1178 # delete all its relations without security checking |
1179 with security_enabled(session, read=False, write=False): |
1179 with security_enabled(session, read=False, write=False): |
1180 eids = [_e.eid for _e in entities] |
1180 in_eids = ','.join([str(_e.eid) for _e in entities]) |
1181 in_eids = ','.join((str(eid) for eid in eids)) |
|
1182 for rschema, _, role in entities[0].e_schema.relation_definitions(): |
1181 for rschema, _, role in entities[0].e_schema.relation_definitions(): |
1183 rtype = rschema.type |
1182 rtype = rschema.type |
1184 if rtype in schema.VIRTUAL_RTYPES or rtype in pendingrtypes: |
1183 if rtype in schema.VIRTUAL_RTYPES or rtype in pendingrtypes: |
1185 continue |
1184 continue |
1186 if role == 'subject': |
1185 if role == 'subject': |
1421 if server.DEBUG & server.DBG_REPO: |
1420 if server.DEBUG & server.DBG_REPO: |
1422 print 'DELETE entities', etype, [entity.eid for entity in entities] |
1421 print 'DELETE entities', etype, [entity.eid for entity in entities] |
1423 source = self.sources_by_uri[sourceuri] |
1422 source = self.sources_by_uri[sourceuri] |
1424 if source.should_call_hooks: |
1423 if source.should_call_hooks: |
1425 self.hm.call_hooks('before_delete_entity', session, entities=entities) |
1424 self.hm.call_hooks('before_delete_entity', session, entities=entities) |
1426 self._delete_info_multi(session, entities, sourceuri) |
1425 if session.deleted_in_transaction(source.eid): |
|
1426 # source is being deleted, think to give scleanup argument |
|
1427 self._delete_info_multi(session, entities, sourceuri, scleanup=source.eid) |
|
1428 else: |
|
1429 self._delete_info_multi(session, entities, sourceuri) |
1427 source.delete_entities(session, entities) |
1430 source.delete_entities(session, entities) |
1428 if source.should_call_hooks: |
1431 if source.should_call_hooks: |
1429 self.hm.call_hooks('after_delete_entity', session, entities=entities) |
1432 self.hm.call_hooks('after_delete_entity', session, entities=entities) |
1430 # don't clear cache here, it is done in a hook on commit |
1433 # don't clear cache here, it is done in a hook on commit |
1431 |
1434 |