Branch 'pykolab-0.4' - 3 commits - configure.ac pykolab/auth

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed Sep 12 10:47:16 CEST 2012


 configure.ac                  |    4 -
 pykolab/auth/ldap/__init__.py |   87 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 2 deletions(-)

New commits:
commit 49b8458e621d37e414d47be62b252b905701e686
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Sep 12 09:46:42 2012 +0100

    Bump teeny release

diff --git a/configure.ac b/configure.ac
index bf3a746..365379c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
-AC_INIT([pykolab], 0.4.14)
-AC_SUBST([RELEASE], 3)
+AC_INIT([pykolab], 0.4.15)
+AC_SUBST([RELEASE], 1)
 
 AC_CONFIG_SRCDIR(pykolab/constants.py.in)
 


commit ea58788f15fcc7153ae01b795274b906c4f99ec1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Sep 12 09:46:00 2012 +0100

    Set the mail server attribute to the actual mail server being used

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 6144e5f..58035bf 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1169,6 +1169,14 @@ class LDAP(pykolab.base.Base):
 
             self.user_quota(entry, folder)
 
+            mailserver_attr = self.config_get('mailserver_attribute')
+            if not entry.has_key(mailserver_attr):
+                self.set_entry_attribute(entry, mailserver_attr, server)
+            else:
+                if not entry[mailserver_attr] == server:
+                    # TODO: Should actually transfer mailbox
+                    self.set_entry_attribute(entry, mailserver_attr, server)
+
         else:
             log.warning(
                     _("Kolab user %s does not have a result attribute %r") % (


commit 8585a0ce21d87314d4ce762cd4e6cfe1d0b612c1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Sep 12 09:43:42 2012 +0100

    Add function user_quota()
    Call function user_quota() on changes add, delete and none for user entries

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index d98dfa9..6144e5f 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -704,6 +704,72 @@ class LDAP(pykolab.base.Base):
                 callback=self._synchronize_callback,
             )
 
+    def user_quota(self, entry_id, folder):
+        default_quota = self.config_get('default_quota')
+        quota_attribute = self.config_get('quota_attribute')
+
+        if quota_attribute == None:
+            return
+
+        if default_quota == None:
+            return
+
+        self._bind()
+
+        entry_dn = self.entry_dn(entry_id)
+
+        current_ldap_quota = self.get_entry_attribute(entry_dn, quota_attribute)
+        _imap_quota = self.imap.get_quota(folder)
+
+        if _imap_quota == None:
+            used = None
+            current_imap_quota = None
+        else:
+            (used, current_imap_quota) = _imap_quota
+
+        log.debug(
+                _("About to consider the user quota for %r (used: %r, " + \
+                    "imap: %r, ldap: %r, default: %r") % (
+                        entry_dn,
+                        used,
+                        current_imap_quota,
+                        current_ldap_quota,
+                        default_quota
+                    ),
+                level=9
+            )
+
+        new_quota = conf.plugins.exec_hook("set_user_folder_quota", kw={
+                    'used': used,
+                    'imap_quota': current_imap_quota,
+                    'ldap_quota': current_ldap_quota,
+                    'default_quota': default_quota
+                }
+            )
+
+        if not current_ldap_quota == None:
+            if not new_quota == (int)(current_ldap_quota):
+                self.set_entry_attribute(
+                        entry_dn,
+                        quota_attribute,
+                        "%s" % (new_quota)
+                    )
+        else:
+            if not new_quota == None:
+                self.set_entry_attribute(
+                        entry_dn,
+                        quota_attribute,
+                        "%s" % (new_quota)
+                    )
+
+        if not current_imap_quota == None:
+            if not new_quota == current_imap_quota:
+                self.imap.set_quota(folder, new_quota)
+
+        else:
+            if not new_quota == None:
+                self.imap.set_quota(folder, new_quota)
+
     ###
     ### API depth level increasing!
     ###
@@ -771,6 +837,8 @@ class LDAP(pykolab.base.Base):
         if not entry[mailserver_attribute] == server:
             self.set_entry_attribute(entry, mailserver_attribute, server)
 
+        self.user_quota(entry, folder)
+
     def _change_add_group(self, entry, change):
         """
             An entry of type group was added.
@@ -996,6 +1064,8 @@ class LDAP(pykolab.base.Base):
                 self.imap.user_mailbox_rename(old_canon_attr, entry_changes[result_attribute])
                 conf.changelog[entry['id']] = entry_changes[result_attribute]
 
+        self.user_quota(entry, "user%s%s" % (self.imap.separator,entry[result_attribute]))
+
     def _change_none_group(self, entry, change):
         """
             A group entry as part of the initial search result set.
@@ -1089,6 +1159,15 @@ class LDAP(pykolab.base.Base):
             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:
+                folder = "user%s%s" % (
+                        self.imap.separator,
+                        entry[result_attribute]
+                    )
+
+                server = self.imap.user_mailbox_server(folder)
+
+            self.user_quota(entry, folder)
 
         else:
             log.warning(





More information about the commits mailing list