def create_or_replace (self, dn, entry):
        try:
            if settings.LDAP_MASTER_DISABLE == True: return
        except __HOLE__: pass
        count = 0
        while 1:
            try:
                resultid = self.proxy.search(dn, ldap.SCOPE_BASE)
                try:
                    t, data = self.proxy.result(resultid, 1)
                    logger.debug("LdapProxy.create_or_replace: dn %s exists and is going to be deleted before being inserted again" % (dn))
                    self.proxy.delete_s(dn)
                except ldap.NO_SUCH_OBJECT:
                    pass
                logger.debug("LdapProxy.create_or_replace: adding %s [%s]" % (dn, entry))
                self.proxy.add_s(dn,ldap.modlist.addModlist(entry))
                break
            except ldap.ALREADY_EXISTS:
                count = count + 1
                if count < settings.LDAP_MASTER_RETRIES:
                    continue
                else:
                    logger.error ("LdapProxy: tried %d time to replace %s in LDAP directory" % (settings.LDAP_MASTER_RETRIES, dn))
                    raise
            except ldap.LDAPError, error_message:
                logger.error ("ldapproxy: create or replace %s with %s failed: %s" % (dn, entry, error_message))
                raise
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/ldapproxy/models.py/LdapProxy.create_or_replace