201 try: |
201 try: |
202 eid = self.extid2eid(str(extid), etype, session, |
202 eid = self.extid2eid(str(extid), etype, session, |
203 insert=False) |
203 insert=False) |
204 # entity has been deleted from external repository but is not known here |
204 # entity has been deleted from external repository but is not known here |
205 if eid is not None: |
205 if eid is not None: |
206 repo.delete_info(session, eid) |
206 entity = session.entity_from_eid(eid, etype) |
|
207 repo.delete_info(session, entity, self.uri, extid) |
207 except: |
208 except: |
208 self.exception('while updating %s with external id %s of source %s', |
209 self.exception('while updating %s with external id %s of source %s', |
209 etype, extid, self.uri) |
210 etype, extid, self.uri) |
210 continue |
211 continue |
211 session.execute('SET X value %(v)s WHERE X pkey %(k)s', |
212 session.execute('SET X value %(v)s WHERE X pkey %(k)s', |
348 cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations), |
349 cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations), |
349 kwargs, 'x') |
350 kwargs, 'x') |
350 self._query_cache.clear() |
351 self._query_cache.clear() |
351 entity.clear_all_caches() |
352 entity.clear_all_caches() |
352 |
353 |
353 def delete_entity(self, session, etype, eid): |
354 def delete_entity(self, session, entity): |
354 """delete an entity from the source""" |
355 """delete an entity from the source""" |
355 cu = session.pool[self.uri] |
356 cu = session.pool[self.uri] |
356 cu.execute('DELETE %s X WHERE X eid %%(x)s' % etype, |
357 cu.execute('DELETE %s X WHERE X eid %%(x)s' % entity.__regid__, |
357 {'x': self.eid2extid(eid, session)}, 'x') |
358 {'x': self.eid2extid(entity.eid, session)}, 'x') |
358 self._query_cache.clear() |
359 self._query_cache.clear() |
359 |
360 |
360 def add_relation(self, session, subject, rtype, object): |
361 def add_relation(self, session, subject, rtype, object): |
361 """add a relation to the source""" |
362 """add a relation to the source""" |
362 cu = session.pool[self.uri] |
363 cu = session.pool[self.uri] |