# HG changeset patch # User Sylvain Thénault # Date 1317293720 -7200 # Node ID 35d2e2f4e10aafc8bd76578ca747f656ab940814 # Parent cd98785b4a84d96946acc0ff9c1948a7e10169c8 [repo] cleanup [_]delete_info prototype: extid argument isn't used diff -r cd98785b4a84 -r 35d2e2f4e10a misc/scripts/drop_external_entities.py --- a/misc/scripts/drop_external_entities.py Tue Sep 27 09:26:40 2011 +0200 +++ b/misc/scripts/drop_external_entities.py Thu Sep 29 12:55:20 2011 +0200 @@ -15,7 +15,7 @@ if suri != 'system': try: print 'deleting', e.__regid__, e.eid, suri, e.dc_title().encode('utf8') - repo.delete_info(session, e, suri, meta['extid'], scleanup=True) + repo.delete_info(session, e, suri, scleanup=e.eid) except UnknownEid: print ' cant delete', e.__regid__, e.eid, meta diff -r cd98785b4a84 -r 35d2e2f4e10a server/repository.py --- a/server/repository.py Tue Sep 27 09:26:40 2011 +0200 +++ b/server/repository.py Thu Sep 29 12:55:20 2011 +0200 @@ -1106,20 +1106,28 @@ hook.CleanupNewEidsCacheOp.get_instance(session).add_data(entity.eid) self.system_source.add_info(session, entity, source, extid, complete) - def delete_info(self, session, entity, sourceuri, extid, scleanup=None): + def delete_info(self, session, entity, sourceuri, scleanup=None): """called by external source when some entity known by the system source has been deleted in the external source """ # mark eid as being deleted in session info and setup cache update # operation hook.CleanupDeletedEidsCacheOp.get_instance(session).add_data(entity.eid) - self._delete_info(session, entity, sourceuri, extid, scleanup) + self._delete_info(session, entity, sourceuri, scleanup) - def _delete_info(self, session, entity, sourceuri, extid, scleanup=None): + def _delete_info(self, session, entity, sourceuri, 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 the entities table to the deleted_entities table + + When scleanup is specified, it's expected to be the source's eid, in + which case we'll specify the target's relation source so that this + source is ignored. E.g. we want to delete relations stored locally, as + the deletion information comes from the external source, it's its + responsability to have cleaned-up its own relations. """ pendingrtypes = session.transaction_data.get('pendingrtypes', ()) # delete remaining relations: if user can delete the entity, he can diff -r cd98785b4a84 -r 35d2e2f4e10a server/sources/ldapuser.py --- a/server/sources/ldapuser.py Tue Sep 27 09:26:40 2011 +0200 +++ b/server/sources/ldapuser.py Thu Sep 29 12:55:20 2011 +0200 @@ -542,7 +542,7 @@ self.warning('deleting ldap user with eid %s and dn %s', eid, base) entity = session.entity_from_eid(eid, 'CWUser') - self.repo.delete_info(session, entity, self.uri, base) + self.repo.delete_info(session, entity, self.uri) self.reset_caches() return [] # except ldap.REFERRAL, e: diff -r cd98785b4a84 -r 35d2e2f4e10a server/sources/pyrorql.py --- a/server/sources/pyrorql.py Tue Sep 27 09:26:40 2011 +0200 +++ b/server/sources/pyrorql.py Thu Sep 29 12:55:20 2011 +0200 @@ -286,7 +286,7 @@ # entity has been deleted from external repository but is not known here if eid is not None: entity = session.entity_from_eid(eid, etype) - repo.delete_info(session, entity, self.uri, extid, + repo.delete_info(session, entity, self.uri, scleanup=self.eid) except Exception: self.exception('while updating %s with external id %s of source %s',