server/sources/pyrorql.py
changeset 7293 97505b798975
parent 6958 861251f125cf
child 7398 26695dd703d8
equal deleted inserted replaced
7285:39437617f3f0 7293:97505b798975
   435         """update an entity in the source"""
   435         """update an entity in the source"""
   436         relations, kwargs = self._entity_relations_and_kwargs(session, entity)
   436         relations, kwargs = self._entity_relations_and_kwargs(session, entity)
   437         cu = session.pool[self.uri]
   437         cu = session.pool[self.uri]
   438         cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations), kwargs)
   438         cu.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations), kwargs)
   439         self._query_cache.clear()
   439         self._query_cache.clear()
   440         entity.clear_all_caches()
   440         entity.cw_clear_all_caches()
   441 
   441 
   442     def delete_entity(self, session, entity):
   442     def delete_entity(self, session, entity):
   443         """delete an entity from the source"""
   443         """delete an entity from the source"""
   444         cu = session.pool[self.uri]
   444         cu = session.pool[self.uri]
   445         cu.execute('DELETE %s X WHERE X eid %%(x)s' % entity.__regid__,
   445         cu.execute('DELETE %s X WHERE X eid %%(x)s' % entity.__regid__,
   451         cu = session.pool[self.uri]
   451         cu = session.pool[self.uri]
   452         cu.execute('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   452         cu.execute('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   453                    {'x': self.eid2extid(subject, session),
   453                    {'x': self.eid2extid(subject, session),
   454                     'y': self.eid2extid(object, session)})
   454                     'y': self.eid2extid(object, session)})
   455         self._query_cache.clear()
   455         self._query_cache.clear()
   456         session.entity_from_eid(subject).clear_all_caches()
   456         session.entity_from_eid(subject).cw_clear_all_caches()
   457         session.entity_from_eid(object).clear_all_caches()
   457         session.entity_from_eid(object).cw_clear_all_caches()
   458 
   458 
   459     def delete_relation(self, session, subject, rtype, object):
   459     def delete_relation(self, session, subject, rtype, object):
   460         """delete a relation from the source"""
   460         """delete a relation from the source"""
   461         cu = session.pool[self.uri]
   461         cu = session.pool[self.uri]
   462         cu.execute('DELETE X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   462         cu.execute('DELETE X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % rtype,
   463                    {'x': self.eid2extid(subject, session),
   463                    {'x': self.eid2extid(subject, session),
   464                     'y': self.eid2extid(object, session)})
   464                     'y': self.eid2extid(object, session)})
   465         self._query_cache.clear()
   465         self._query_cache.clear()
   466         session.entity_from_eid(subject).clear_all_caches()
   466         session.entity_from_eid(subject).cw_clear_all_caches()
   467         session.entity_from_eid(object).clear_all_caches()
   467         session.entity_from_eid(object).cw_clear_all_caches()
   468 
   468 
   469 
   469 
   470 class RQL2RQL(object):
   470 class RQL2RQL(object):
   471     """translate a local rql query to be executed on a distant repository"""
   471     """translate a local rql query to be executed on a distant repository"""
   472     def __init__(self, source):
   472     def __init__(self, source):