Branch 'pykolab-0.4' - 3 commits - pykolab/auth

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Thu May 10 17:45:23 CEST 2012


 pykolab/auth/ldap/__init__.py |   17 +++++++++++++----
 pykolab/auth/ldap/cache.py    |    5 +++--
 2 files changed, 16 insertions(+), 6 deletions(-)

New commits:
commit 4641f5657da5e8feebfe057110346c80d0ba34f1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu May 10 16:39:52 2012 +0100

    Add back the cache.get_entry() routine

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 5793dc5..3d5b699 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1076,7 +1076,7 @@ class LDAP(pykolab.base.Base):
         for key in rcpt_addrs.keys():
             entry[key] = rcpt_addrs[key]
 
-        #cache.get_entry(self.domain, entry)
+        cache.get_entry(self.domain, entry)
 
         self.imap.connect(domain=self.domain)
 


commit dbdff396e1b029f9525f609e2947dffbc748efd7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu May 10 16:39:08 2012 +0100

    Do not attempt to create a mailbox if no value for the result attribute we're looking for exists (#750)

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 2f01ba3..5793dc5 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1080,9 +1080,18 @@ class LDAP(pykolab.base.Base):
 
         self.imap.connect(domain=self.domain)
 
-        if not self.imap.user_mailbox_exists(entry[result_attribute]):
-            folder = self.imap.user_mailbox_create(entry[result_attribute])
-            server = self.imap.user_mailbox_server(folder)
+        if entry.has_key(result_attribute) and not entry.has_key(result_attribute) == None:
+            if not self.imap.user_mailbox_exists(entry[result_attribute]):
+                folder = self.imap.user_mailbox_create(entry[result_attribute])
+                server = self.imap.user_mailbox_server(folder)
+
+        else:
+            log.warning(
+                    _("Kolab user %s does not have a result attribute %r") % (
+                            entry['id'],
+                            result_attribute
+                        )
+                )
 
     def _disconnect(self):
         self._unbind()


commit 4099ec6f9880814bec528fb5a2967b66ae6dd3a0
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu May 10 16:38:07 2012 +0100

    Correct cache.get_entry() use of strtime (should have been strftime) and Python native datetime objects (we were passing the literal string)

diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py
index 30f87fe..69c5d8d 100644
--- a/pykolab/auth/ldap/cache.py
+++ b/pykolab/auth/ldap/cache.py
@@ -118,9 +118,10 @@ def get_entry(domain, entry):
         db.commit()
         _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
     else:
-        if not _entry.last_change.strtime("%Y%m%d%H%M%SZ") == entry['modifytimestamp']:
+        if not _entry.last_change.strftime("%Y%m%d%H%M%SZ") == entry['modifytimestamp']:
             log.debug(_("Updating timestamp for cache entry %r") % (entry['id']), level=8)
-            entry.last_change = entry['modifytimestamp']
+            last_change = datetime.datetime.strptime(entry['modifytimestamp'], "%Y%m%d%H%M%SZ")
+            _entry.last_change = last_change
             db.commit()
             _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
 





More information about the commits mailing list