# HG changeset patch # User Julien Cristau # Date 1451900217 -3600 # Node ID 615163b1755850e02deaeda63316f4c4db833243 # Parent 00c5ee272a6d5a1452a99dc860b371f9db33c4ed [ldapfeed] extid and cwuri aren't the same thing Historically, we used a ldap://... URI as cwuri attribute, not just the dn. The extid field, OTOH, was always the dn. So when initializing our dict of known entities from an ldap source, look at existing extids, not cwuris, to avoid importing already-existing users (and violated unicity constraints). diff -r 00c5ee272a6d -r 615163b17558 sobjects/ldapparser.py --- a/sobjects/ldapparser.py Wed Dec 23 15:44:28 2015 +0100 +++ b/sobjects/ldapparser.py Mon Jan 04 10:36:57 2016 +0100 @@ -120,8 +120,8 @@ def build_importer(self, raise_on_error): """Instantiate and configure an importer""" etypes = ('CWUser', 'EmailAddress', 'CWGroup') - extid2eid = dict((x.encode('ascii'), y) for x, y in - importer.cwuri2eid(self._cw, etypes, source_eid=self.source.eid).items()) + extid2eid = dict((self.source.decode_extid(x), y) for x, y in + self._cw.system_sql('select extid, eid from entities where asource = %(s)s', {'s': self.source.uri})) existing_relations = {} for rtype in ('in_group', 'use_email', 'owned_by'): rql = 'Any S,O WHERE S {} O, S cw_source SO, SO eid %(s)s'.format(rtype)