2 commits - pykolab/auth pykolab/cli pykolab/plugins

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Tue Feb 11 11:34:38 CET 2014


 pykolab/auth/ldap/cache.py            |   20 +++++++++++++++++---
 pykolab/cli/sieve/cmd_refresh.py      |    2 +-
 pykolab/plugins/sievemgmt/__init__.py |    2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

New commits:
commit 78ed8f6bdce55e01c23bb51e328c866bff46fafa
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Feb 11 09:53:14 2014 +0100

    Fix typos

diff --git a/pykolab/cli/sieve/cmd_refresh.py b/pykolab/cli/sieve/cmd_refresh.py
index 496f31f..6c10dfa 100644
--- a/pykolab/cli/sieve/cmd_refresh.py
+++ b/pykolab/cli/sieve/cmd_refresh.py
@@ -97,7 +97,7 @@ def execute(*args, **kw):
         active, scripts = result
 
     log.debug(_("Found the following scripts for user %s: %s") % (address, ','.join(scripts)), level=8)
-    log.deubg(_("And the following script is active for user %s: %s") % (address, active), level=8)
+    log.debug(_("And the following script is active for user %s: %s") % (address, active), level=8)
 
     mgmt_required_extensions = []
 
diff --git a/pykolab/plugins/sievemgmt/__init__.py b/pykolab/plugins/sievemgmt/__init__.py
index 32dbdf5..42297a4 100644
--- a/pykolab/plugins/sievemgmt/__init__.py
+++ b/pykolab/plugins/sievemgmt/__init__.py
@@ -109,7 +109,7 @@ class KolabSievemgmt(object):
             active, scripts = result
 
         log.debug(_("Found the following scripts for user %s: %s") % (address, ','.join(scripts)), level=8)
-        log.deubg(_("And the following script is active for user %s: %s") % (address, active), level=8)
+        log.debug(_("And the following script is active for user %s: %s") % (address, active), level=8)
 
         mgmt_required_extensions = []
 


commit 5bb9406b9a35747f51af637a01da29135d3dd95d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon Feb 10 22:52:02 2014 +0100

    Allow the cache to be reinitialized automatically

diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py
index 55a47c3..ad50e9b 100644
--- a/pykolab/auth/ldap/cache.py
+++ b/pykolab/auth/ldap/cache.py
@@ -107,8 +107,17 @@ def delete_entry(domain, entry):
 def get_entry(domain, entry, update=True):
     result_attribute = conf.get('cyrus-sasl', 'result_attribute')
 
+    _entry = None
+
     db = init_db(domain)
-    _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
+    try:
+        _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
+    except sqlalchemy.exc.OperationalError, errmsg:
+        db = init_db(domain,reinit=True)
+    except sqlalchemy.exc.InvalidRequestError, errmsg:
+        db = init_db(domain,reinit=True)
+    finally:
+        _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
 
     if not update:
         return _entry
@@ -149,15 +158,20 @@ def get_entry(domain, entry, update=True):
 
     return _entry
 
-def init_db(domain):
+def init_db(domain,reinit=False):
     """
         Returns a SQLAlchemy Session() instance.
     """
     global db
 
-    if not db == None:
+    if not db == None and not reinit:
         return db
 
+    if reinit:
+        import os
+        if os.path.isfile('sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain)):
+            os.unlink('sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain))
+
     db_uri = 'sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain)
     echo = conf.debuglevel > 8
     engine = create_engine(db_uri, echo=echo)




More information about the commits mailing list