sobjects/ldapparser.py
changeset 11045 615163b17558
parent 11037 621ad47c7c86
equal deleted inserted replaced
11044:00c5ee272a6d 11045:615163b17558
   118                          {'s': self.source.eid})
   118                          {'s': self.source.eid})
   119 
   119 
   120     def build_importer(self, raise_on_error):
   120     def build_importer(self, raise_on_error):
   121         """Instantiate and configure an importer"""
   121         """Instantiate and configure an importer"""
   122         etypes = ('CWUser', 'EmailAddress', 'CWGroup')
   122         etypes = ('CWUser', 'EmailAddress', 'CWGroup')
   123         extid2eid = dict((x.encode('ascii'), y) for x, y in
   123         extid2eid = dict((self.source.decode_extid(x), y) for x, y in
   124                 importer.cwuri2eid(self._cw, etypes, source_eid=self.source.eid).items())
   124                 self._cw.system_sql('select extid, eid from entities where asource = %(s)s', {'s': self.source.uri}))
   125         existing_relations = {}
   125         existing_relations = {}
   126         for rtype in ('in_group', 'use_email', 'owned_by'):
   126         for rtype in ('in_group', 'use_email', 'owned_by'):
   127             rql = 'Any S,O WHERE S {} O, S cw_source SO, SO eid %(s)s'.format(rtype)
   127             rql = 'Any S,O WHERE S {} O, S cw_source SO, SO eid %(s)s'.format(rtype)
   128             rset = self._cw.execute(rql, {'s': self.source.eid})
   128             rset = self._cw.execute(rql, {'s': self.source.eid})
   129             existing_relations[rtype] = set(tuple(x) for x in rset)
   129             existing_relations[rtype] = set(tuple(x) for x in rset)