# HG changeset patch # User Sylvain Thénault # Date 1453880284 -3600 # Node ID 891f3ecdbf7f6a44dd6108b7604308496c4f009a # Parent 4c000e0987ec0ab31aa97acf63ef050f1d62764b [dataimport] rephrase minor bits of the meta generator diff -r 4c000e0987ec -r 891f3ecdbf7f cubicweb/dataimport/stores.py --- a/cubicweb/dataimport/stores.py Tue Jun 21 15:25:36 2016 +0200 +++ b/cubicweb/dataimport/stores.py Wed Jan 27 08:38:04 2016 +0100 @@ -264,9 +264,7 @@ self.etype_rels = [] # attributes/relations specific to each entity self.entity_attrs = ['cwuri'] - #self.entity_rels = [] XXX not handled (YAGNI?) - schema = cnx.vreg.schema - rschema = schema.rschema + rschema = cnx.vreg.schema.rschema for rtype in self.META_RELATIONS: # skip owned_by / created_by if user is the internal manager if cnx.user.eid == -1 and rtype in ('owned_by', 'created_by'): @@ -295,7 +293,10 @@ def init_entity(self, entity): entity.eid = self.create_eid(self._cnx) + # if cwuri is specified, this is an extid. It's not if it's generated in the above loop extid = entity.cw_edited.get('cwuri') + if isinstance(extid, text_type): + extid = extid.encode('utf-8') for attr in self.entity_attrs: if attr in entity.cw_edited: # already set, skip this attribute @@ -303,8 +304,6 @@ genfunc = self.generate(attr) if genfunc: entity.cw_edited.edited_attribute(attr, genfunc(entity)) - if isinstance(extid, text_type): - extid = extid.encode('utf-8') return self.source, extid def generate(self, rtype):