summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-02-10 12:50:07 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-02-10 12:50:07 +0100
commit1650125059262170e49c93eceea2194c1ad92d99 (patch)
tree0866d01819b240ba8e163adc8bcf1188c96d7ebd
parent4545838d331983041ad6ef06af327162a2a6cf28 (diff)
downloadpykolab-1650125059262170e49c93eceea2194c1ad92d99.tar.gz
Allow entries to be deleted, to address stale cache entries
-rw-r--r--pykolab/auth/ldap/auth_cache.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/pykolab/auth/ldap/auth_cache.py b/pykolab/auth/ldap/auth_cache.py
index 35fbebb..488deac 100644
--- a/pykolab/auth/ldap/auth_cache.py
+++ b/pykolab/auth/ldap/auth_cache.py
@@ -86,6 +86,11 @@ mapper(Entry, entry_table)
## Functions
##
+def del_entry(key):
+ db = init_db()
+ _entries = db.query(Entry).filter_by(key=key).delete()
+ db.commit()
+
def get_entry(key):
db = init_db()
_entries = db.query(Entry).filter_by(key=key).all()
@@ -113,6 +118,12 @@ def set_entry(key, value):
)
db.commit()
+ elif len(_entries) == 1:
+ if not _entries[0].value == value:
+ _entries[0].value = value
+
+ _entries[0].last_change = datetime.datetime.now()
+ db.commit()
def purge_entries(db):
db.query(Entry).filter(Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(1))).delete()