# HG changeset patch # User Sylvain Thénault # Date 1297087984 -3600 # Node ID 9ed02daa7dbb53d4767e73bbe38daf40a5533d5b # Parent 1599ad09624f4c9e33106c4f2bff3af578bfc0a2 [repo, ms] optimise external source deletion by using source's eid instead of name diff -r 1599ad09624f -r 9ed02daa7dbb server/repository.py --- a/server/repository.py Tue Feb 01 11:03:08 2011 +0100 +++ b/server/repository.py Mon Feb 07 15:13:04 2011 +0100 @@ -1091,7 +1091,7 @@ op.add_data(entity.eid) self._delete_info_multi(session, entities, sourceuri, extids, scleanup) - def _delete_info(self, session, entity, sourceuri, extid, scleanup=False): + def _delete_info(self, session, entity, sourceuri, extid, scleanup=None): """delete system information on deletion of an entity: * delete all remaining relations from/to this entity * call delete info on the system source which will transfer record from @@ -1112,11 +1112,12 @@ rql = 'DELETE X %s Y WHERE X eid %%(x)s' % rtype else: rql = 'DELETE Y %s X WHERE X eid %%(x)s' % rtype - if scleanup: + if scleanup is not None: # source cleaning: only delete relations stored locally - rql += ', NOT (Y cw_source S, S name %(source)s)' + # (here, scleanup + rql += ', NOT (Y cw_source S, S eid %(seid)s)' try: - session.execute(rql, {'x': eid, 'source': sourceuri}, + session.execute(rql, {'x': eid, 'seid': scleanup}, build_descr=False) except: self.exception('error while cascading delete for entity %s ' @@ -1144,12 +1145,11 @@ rql = 'DELETE X %s Y WHERE X eid IN (%s)' % (rtype, in_eids) else: rql = 'DELETE Y %s X WHERE X eid IN (%s)' % (rtype, in_eids) - if scleanup: + if scleanup is not None: # source cleaning: only delete relations stored locally - rql += ', NOT (Y cw_source S, S name %(source)s)' + rql += ', NOT (Y cw_source S, S eid %(seid)s)' try: - session.execute(rql, {'source': sourceuri}, - build_descr=False) + session.execute(rql, {'seid': scleanup}, build_descr=False) except: self.exception('error while cascading delete for entity %s ' 'from %s. RQL: %s', entities, sourceuri, rql) diff -r 1599ad09624f -r 9ed02daa7dbb server/sources/pyrorql.py --- a/server/sources/pyrorql.py Tue Feb 01 11:03:08 2011 +0100 +++ b/server/sources/pyrorql.py Mon Feb 07 15:13:04 2011 +0100 @@ -257,7 +257,7 @@ if eid is not None: entity = session.entity_from_eid(eid, etype) repo.delete_info(session, entity, self.uri, extid, - scleanup=True) + scleanup=self.eid) except: self.exception('while updating %s with external id %s of source %s', etype, extid, self.uri)