server/sources/native.py
changeset 6851 824d5b6eae7f
parent 6849 5a0c2cfc19bf
child 6882 b5e34836f84e
equal deleted inserted replaced
6849:5a0c2cfc19bf 6851:824d5b6eae7f
   884             extid = b64encode(extid)
   884             extid = b64encode(extid)
   885         attrs = {'type': entity.__regid__, 'eid': entity.eid, 'extid': extid,
   885         attrs = {'type': entity.__regid__, 'eid': entity.eid, 'extid': extid,
   886                  'source': source.uri, 'mtime': datetime.now()}
   886                  'source': source.uri, 'mtime': datetime.now()}
   887         self.doexec(session, self.sqlgen.insert('entities', attrs), attrs)
   887         self.doexec(session, self.sqlgen.insert('entities', attrs), attrs)
   888         # insert core relations: is, is_instance_of and cw_source
   888         # insert core relations: is, is_instance_of and cw_source
   889         if not hasattr(entity, '_cw_recreating'):
   889         try:
   890             try:
   890             self.doexec(session, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)'
   891                 self.doexec(session, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)'
   891                         % (entity.eid, eschema_eid(session, entity.e_schema)))
   892                             % (entity.eid, eschema_eid(session, entity.e_schema)))
   892         except IndexError:
   893             except IndexError:
   893             # during schema serialization, skip
   894                 # during schema serialization, skip
   894             pass
   895                 pass
   895         else:
   896             else:
   896             for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
   897                 for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
   897                 self.doexec(session, 'INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)'
   898                     self.doexec(session, 'INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)'
   898                            % (entity.eid, eschema_eid(session, eschema)))
   899                                % (entity.eid, eschema_eid(session, eschema)))
   899         if 'CWSource' in self.schema and source.eid is not None: # else, cw < 3.10
   900             if 'CWSource' in self.schema and source.eid is not None: # else, cw < 3.10
   900             self.doexec(session, 'INSERT INTO cw_source_relation(eid_from,eid_to) '
   901                 self.doexec(session, 'INSERT INTO cw_source_relation(eid_from,eid_to) '
   901                         'VALUES (%s,%s)' % (entity.eid, source.eid))
   902                             'VALUES (%s,%s)' % (entity.eid, source.eid))
       
   903         # now we can update the full text index
   902         # now we can update the full text index
   904         if self.do_fti and self.need_fti_indexation(entity.__regid__):
   903         if self.do_fti and self.need_fti_indexation(entity.__regid__):
   905             if complete:
   904             if complete:
   906                 entity.complete(entity.e_schema.indexable_attributes())
   905                 entity.complete(entity.e_schema.indexable_attributes())
   907             self.index_entity(session, entity=entity)
   906             self.index_entity(session, entity=entity)