cubicweb/dataimport/pgstore.py
changeset 11774 51c160677afe
parent 11773 054a947b5415
child 12504 362fdb399ff5
equal deleted inserted replaced
11773:054a947b5415 11774:51c160677afe
   415         self._append_to_entities(sql, attrs)
   415         self._append_to_entities(sql, attrs)
   416 
   416 
   417     # add_info is _copypasted_ from the one in NativeSQLSource. We want it
   417     # add_info is _copypasted_ from the one in NativeSQLSource. We want it
   418     # there because it will use the _handlers of the SQLGenSourceWrapper, which
   418     # there because it will use the _handlers of the SQLGenSourceWrapper, which
   419     # are not like the ones in the native source.
   419     # are not like the ones in the native source.
   420     def add_info(self, cnx, entity, source, extid):
   420     def add_info(self, cnx, entity, source):
   421         """add type and source info for an eid into the system table"""
   421         """add type and source info for an eid into the system table"""
   422         # begin by inserting eid/type/source/extid into the entities table
   422         # begin by inserting eid/type/source into the entities table
   423         if extid is not None:
   423         attrs = {'type': entity.cw_etype, 'eid': entity.eid}
   424             assert isinstance(extid, binary_type)
       
   425             extid = b64encode(extid).decode('ascii')
       
   426         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid}
       
   427         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   424         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   428         # insert core relations: is, is_instance_of and cw_source
   425         # insert core relations: is, is_instance_of and cw_source
   429         self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   426         self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
   430                                      (entity.eid, entity.e_schema.eid))
   427                                      (entity.eid, entity.e_schema.eid))
   431         for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
   428         for eschema in entity.e_schema.ancestors() + [entity.e_schema]: