server/sources/__init__.py
changeset 6931 0af44a38fe41
parent 6724 24bf6f181d0e
parent 6889 37668bf302f5
child 6943 406a41c25e13
equal deleted inserted replaced
6884:6fa712e9dfa5 6931:0af44a38fe41
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 
    21 
    22 from os.path import join, splitext
    22 from os.path import join, splitext
    23 from datetime import datetime, timedelta
    23 from datetime import datetime, timedelta
    24 from logging import getLogger
    24 from logging import getLogger
       
    25 import itertools
    25 
    26 
    26 from cubicweb import set_log_methods, server
    27 from cubicweb import set_log_methods, server
    27 from cubicweb.schema import VIRTUAL_RTYPES
    28 from cubicweb.schema import VIRTUAL_RTYPES
    28 from cubicweb.server.sqlutils import SQL_PREFIX
    29 from cubicweb.server.sqlutils import SQL_PREFIX
    29 from cubicweb.server.ssplanner import EditedEntity
    30 from cubicweb.server.ssplanner import EditedEntity
   372 
   373 
   373     def update_entity(self, session, entity):
   374     def update_entity(self, session, entity):
   374         """update an entity in the source"""
   375         """update an entity in the source"""
   375         raise NotImplementedError()
   376         raise NotImplementedError()
   376 
   377 
       
   378     def delete_entities(self, session, entities):
       
   379         """delete several entities from the source"""
       
   380         for entity in entities:
       
   381             self.delete_entity(session, entity)
       
   382 
   377     def delete_entity(self, session, entity):
   383     def delete_entity(self, session, entity):
   378         """delete an entity from the source"""
   384         """delete an entity from the source"""
   379         raise NotImplementedError()
   385         raise NotImplementedError()
   380 
   386 
   381     def add_relation(self, session, subject, rtype, object):
   387     def add_relation(self, session, subject, rtype, object):
   401 
   407 
   402     def update_info(self, session, entity, need_fti_update):
   408     def update_info(self, session, entity, need_fti_update):
   403         """mark entity as being modified, fulltext reindex if needed"""
   409         """mark entity as being modified, fulltext reindex if needed"""
   404         raise NotImplementedError()
   410         raise NotImplementedError()
   405 
   411 
   406     def delete_info(self, session, entity, uri, extid, attributes, relations):
   412     def delete_info(self, session, entity, uri, extid):
   407         """delete system information on deletion of an entity by transfering
   413         """delete system information on deletion of an entity by transfering
   408         record from the entities table to the deleted_entities table
   414         record from the entities table to the deleted_entities table
   409         """
   415         """
   410         raise NotImplementedError()
   416         raise NotImplementedError()
       
   417 
       
   418     def delete_info_multi(self, session, entities, uri, extids):
       
   419         """ame as delete_info but accepts a list of entities with
       
   420         the same etype and belinging to the same source.
       
   421         """
       
   422         for entity, extid in itertools.izip(entities, extids):
       
   423             self.delete_info(session, entity, uri, extid)
   411 
   424 
   412     def modified_entities(self, session, etypes, mtime):
   425     def modified_entities(self, session, etypes, mtime):
   413         """return a 2-uple:
   426         """return a 2-uple:
   414         * list of (etype, eid) of entities of the given types which have been
   427         * list of (etype, eid) of entities of the given types which have been
   415           modified since the given timestamp (actually entities whose full text
   428           modified since the given timestamp (actually entities whose full text
   423         """create an operation to [re]index textual content of the given entity
   436         """create an operation to [re]index textual content of the given entity
   424         on commit
   437         on commit
   425         """
   438         """
   426         raise NotImplementedError()
   439         raise NotImplementedError()
   427 
   440 
   428     def fti_unindex_entity(self, session, eid):
   441     def fti_unindex_entities(self, session, entities):
   429         """remove text content for entity with the given eid from the full text
   442         """remove text content for entities from the full text index
   430         index
   443         """
   431         """
   444         raise NotImplementedError()
   432         raise NotImplementedError()
   445 
   433 
   446     def fti_index_entities(self, session, entities):
   434     def fti_index_entity(self, session, entity):
   447         """add text content of created/modified entities to the full text index
   435         """add text content of a created/modified entity to the full text index
       
   436         """
   448         """
   437         raise NotImplementedError()
   449         raise NotImplementedError()
   438 
   450 
   439     # sql system source interface #############################################
   451     # sql system source interface #############################################
   440 
   452