summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-07-31 15:06:40 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-07-31 15:06:40 +0200
commit8d344ac056a6a987939ca65b4175e96ef7665b2c (patch)
tree8c5f92410e764824b803c523b290fd72d96dba20
parentb00ea314f722fb2ba455e9a90bbd7f7616767946 (diff)
downloadpykolab-8d344ac056a6a987939ca65b4175e96ef7665b2c.tar.gz
If the engine cannot be created (such as when running functional tests as a non-root user), create the cache in memory).
-rw-r--r--pykolab/auth/ldap/__init__.py12
-rw-r--r--pykolab/auth/ldap/cache.py25
2 files changed, 18 insertions, 19 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 7249009..7bfccd7 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1414,7 +1414,7 @@ class LDAP(pykolab.base.Base):
success = True
for _type in ['user','group','role','sharedfolder']:
try:
- eval("self._change_delete_%s(entry, change)" % (_type))
+ eval("success = self._change_delete_%s(entry, change)" % (_type))
except:
success = False
@@ -2243,7 +2243,7 @@ class LDAP(pykolab.base.Base):
try:
entry['type'] = self._entry_type(entry)
except:
- entry['type'] = "unknown"
+ entry['type'] = None
log.debug(_("Entry type: %s") % (entry['type']), level=8)
@@ -2317,14 +2317,6 @@ class LDAP(pykolab.base.Base):
#
# server = self.imap.user_mailbox_server(folder)
- log.debug(
- _("Done with _synchronize_callback() for entry %r") % (
- entry['id']
- ),
- level=9
- )
-
-
def _unbind(self):
"""
Discard the current set of bind credentials.
diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py
index eaf2ffa..07c3d28 100644
--- a/pykolab/auth/ldap/cache.py
+++ b/pykolab/auth/ldap/cache.py
@@ -175,9 +175,13 @@ def init_db(domain,reinit=False):
db_uri = 'sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain)
echo = conf.debuglevel > 8
- engine = create_engine(db_uri, echo=echo)
- metadata.create_all(engine)
+ try:
+ engine = create_engine(db_uri, echo=echo)
+ metadata.create_all(engine)
+ except:
+ engine = create_engine('sqlite://')
+ metadata.create_all(engine)
Session = sessionmaker(bind=engine)
db = Session()
@@ -185,14 +189,17 @@ def init_db(domain,reinit=False):
return db
def last_modify_timestamp(domain):
- db = init_db(domain)
- last_change = db.query(Entry).order_by(desc(Entry.last_change)).first()
-
modifytimestamp_format = conf.get_raw('ldap', 'modifytimestamp_format')
if modifytimestamp_format == None:
modifytimestamp_format = "%Y%m%d%H%M%SZ"
- if not last_change == None:
- return last_change.last_change.strftime(modifytimestamp_format)
-
- return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)
+ try:
+ db = init_db(domain)
+ last_change = db.query(Entry).order_by(desc(Entry.last_change)).first()
+
+ if not last_change == None:
+ return last_change.last_change.strftime(modifytimestamp_format)
+ else:
+ return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)
+ except:
+ return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)