diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-06-05 14:24:29 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-06-05 14:24:29 +0200 |
commit | 8678e417a9cdb7c65c6ebc0c70ab65b79475af68 (patch) | |
tree | be9893aa62e49bea0508e2651d33e5d119c9b5bd | |
parent | 4583e353fcb16fb5de8f2e83d11173d1f784b80a (diff) | |
download | pykolab-8678e417a9cdb7c65c6ebc0c70ab65b79475af68.tar.gz |
Only compare result attribute values if indeed the input has such key
-rw-r--r-- | pykolab/auth/ldap/cache.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py index ad50e9b..9be4c3e 100644 --- a/pykolab/auth/ldap/cache.py +++ b/pykolab/auth/ldap/cache.py @@ -150,11 +150,12 @@ def get_entry(domain, entry, update=True): db.commit() _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() - if not _entry.result_attribute == entry[result_attribute]: - log.debug(_("Updating result_attribute for cache entry %r") % (entry['id']), level=8) - _entry.result_attribute = entry[result_attribute] - db.commit() - _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() + if entry.has_key(result_attribute): + if not _entry.result_attribute == entry[result_attribute]: + log.debug(_("Updating result_attribute for cache entry %r") % (entry['id']), level=8) + _entry.result_attribute = entry[result_attribute] + db.commit() + _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() return _entry |