dataimport/pgstore.py
changeset 11010 09be4709c8c0
parent 11009 d5962fb5bb8e
child 11089 731d217e4a31
equal deleted inserted replaced
11009:d5962fb5bb8e 11010:09be4709c8c0
    24 from time import asctime
    24 from time import asctime
    25 from datetime import date, datetime, time
    25 from datetime import date, datetime, time
    26 from collections import defaultdict
    26 from collections import defaultdict
    27 from base64 import b64encode
    27 from base64 import b64encode
    28 
    28 
    29 from six import string_types, integer_types, text_type
    29 from six import string_types, integer_types, text_type, binary_type
    30 from six.moves import cPickle as pickle, range
    30 from six.moves import cPickle as pickle, range
    31 
    31 
    32 from cubicweb.utils import make_uid
    32 from cubicweb.utils import make_uid
    33 from cubicweb.server.utils import eschema_eid
    33 from cubicweb.server.utils import eschema_eid
    34 from cubicweb.server.sqlutils import SQL_PREFIX
    34 from cubicweb.server.sqlutils import SQL_PREFIX
   417     # are not like the ones in the native source.
   417     # are not like the ones in the native source.
   418     def add_info(self, cnx, entity, source, extid):
   418     def add_info(self, cnx, entity, source, extid):
   419         """add type and source info for an eid into the system table"""
   419         """add type and source info for an eid into the system table"""
   420         # begin by inserting eid/type/source/extid into the entities table
   420         # begin by inserting eid/type/source/extid into the entities table
   421         if extid is not None:
   421         if extid is not None:
   422             assert isinstance(extid, str)
   422             assert isinstance(extid, binary_type)
   423             extid = b64encode(extid)
   423             extid = b64encode(extid).decode('ascii')
   424         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
   424         attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
   425                  'asource': source.uri}
   425                  'asource': source.uri}
   426         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   426         self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
   427         # insert core relations: is, is_instance_of and cw_source
   427         # insert core relations: is, is_instance_of and cw_source
   428         try:
   428         try: