server/sources/pyrorql.py
branchstable
changeset 3315 59220b704562
parent 3043 7bcb7f1c0f46
child 3527 efeb16ff93f3
equal deleted inserted replaced
3298:caef98aa4a98 3315:59220b704562
   343         relations, kwargs = self._entity_relations_and_kwargs(session, entity)
   343         relations, kwargs = self._entity_relations_and_kwargs(session, entity)
   344         cu = session.pool[self.uri]
   344         cu = session.pool[self.uri]
   345         cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations),
   345         cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations),
   346                    kwargs, 'x')
   346                    kwargs, 'x')
   347         self._query_cache.clear()
   347         self._query_cache.clear()
       
   348         entity.clear_all_caches()
   348 
   349 
   349     def delete_entity(self, session, etype, eid):
   350     def delete_entity(self, session, etype, eid):
   350         """delete an entity from the source"""
   351         """delete an entity from the source"""
   351         cu = session.pool[self.uri]
   352         cu = session.pool[self.uri]
   352         cu.execute('DELETE %s X WHERE X eid %%(x)s' % etype,
   353         cu.execute('DELETE %s X WHERE X eid %%(x)s' % etype,
   358         cu = session.pool[self.uri]
   359         cu = session.pool[self.uri]
   359         cu.execute('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   360         cu.execute('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   360                    {'x': self.eid2extid(subject, session),
   361                    {'x': self.eid2extid(subject, session),
   361                     'y': self.eid2extid(object, session)}, ('x', 'y'))
   362                     'y': self.eid2extid(object, session)}, ('x', 'y'))
   362         self._query_cache.clear()
   363         self._query_cache.clear()
       
   364         session.entity_from_eid(subject).clear_all_caches()
       
   365         session.entity_from_eid(object).clear_all_caches()
   363 
   366 
   364     def delete_relation(self, session, subject, rtype, object):
   367     def delete_relation(self, session, subject, rtype, object):
   365         """delete a relation from the source"""
   368         """delete a relation from the source"""
   366         cu = session.pool[self.uri]
   369         cu = session.pool[self.uri]
   367         cu.execute('DELETE X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   370         cu.execute('DELETE X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   368                    {'x': self.eid2extid(subject, session),
   371                    {'x': self.eid2extid(subject, session),
   369                     'y': self.eid2extid(object, session)}, ('x', 'y'))
   372                     'y': self.eid2extid(object, session)}, ('x', 'y'))
   370         self._query_cache.clear()
   373         self._query_cache.clear()
       
   374         session.entity_from_eid(subject).clear_all_caches()
       
   375         session.entity_from_eid(object).clear_all_caches()
   371 
   376 
   372 
   377 
   373 class RQL2RQL(object):
   378 class RQL2RQL(object):
   374     """translate a local rql query to be executed on a distant repository"""
   379     """translate a local rql query to be executed on a distant repository"""
   375     def __init__(self, source):
   380     def __init__(self, source):