Branch 'pykolab-0.5' - 3 commits - kolabd/process.py pykolab/auth
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed Dec 26 17:27:08 CET 2012
kolabd/process.py | 19 +++++++-----
pykolab/auth/ldap/__init__.py | 65 +++++++++++++++++++++++++++---------------
2 files changed, 55 insertions(+), 29 deletions(-)
New commits:
commit 7099803125af47ce2ddaf1da4159d1930a2eabf3
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 17:26:00 2012 +0100
Continuously loop through the synchronization, sleeping 1 second each run - except when a keyboard interrupt is issued
diff --git a/kolabd/process.py b/kolabd/process.py
index ddaac63..30b5065 100644
--- a/kolabd/process.py
+++ b/kolabd/process.py
@@ -37,10 +37,15 @@ class KolabdProcess(multiprocessing.Process):
)
def synchronize(self, domain):
- try:
- auth = Auth(domain)
- auth.connect(domain)
- auth.synchronize()
- except:
- log.error(_("Error in process %r, terminating") % (self.name))
- return
\ No newline at end of file
+ while True:
+ try:
+ auth = Auth(domain)
+ auth.connect(domain)
+ auth.synchronize()
+ except KeyboardInterrupt:
+ break
+ except Exception, errmsg:
+ log.error(_("Error in process %r, terminating: %r") % (self.name, errmsg))
+ import traceback
+ traceback.print_exc()
+ time.sleep(1)
commit 8c726c54842e69426eb6d689ea6317eef91af61c
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 16:24:46 2012 +0100
Take in to account a _change_none_user can still require a mailbox rename
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 5213bca..f6fcb77 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1355,10 +1355,34 @@ class LDAP(pykolab.base.Base):
"""
result_attribute = conf.get('cyrus-sasl', 'result_attribute')
- rcpt_addrs = self.recipient_policy(entry)
+ old_canon_attr = None
- for key in rcpt_addrs.keys():
- entry[key] = rcpt_addrs[key]
+ _entry = cache.get_entry(self.domain, entry, update=False)
+
+ if not _entry == None and _entry.__dict__.has_key('result_attribute') and not _entry.result_attribute == '':
+ old_canon_attr = _entry.result_attribute
+
+ entry_changes = self.recipient_policy(entry)
+
+ if entry.has_key(result_attribute) and entry_changes.has_key(result_attribute):
+ if not entry[result_attribute] == entry_changes[result_attribute]:
+ old_canon_attr = entry[result_attribute]
+
+ log.debug(
+ _("Result from recipient policy: %r") % (entry_changes),
+ level=8
+ )
+
+ if entry_changes.has_key(result_attribute) and not old_canon_attr == None:
+ if not entry_changes[result_attribute] == old_canon_attr:
+ self.imap.user_mailbox_rename(
+ old_canon_attr,
+ entry_changes[result_attribute]
+ )
+
+ for key in entry_changes.keys():
+ entry[key] = entry_changes[key]
+ self.set_entry_attribute(entry, key, entry[key])
cache.get_entry(self.domain, entry)
commit 7404e83d8c639db6948321dafaf5341972c476af
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Dec 26 14:39:24 2012 +0100
Apply the recipient policy to entries with existing attributes as well (so mailboxes get renamed and such).
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index d96270c..5213bca 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -523,12 +523,14 @@ class LDAP(pykolab.base.Base):
log.debug(_("sec. mail pol. is not empty"))
want_attrs.append(_mail_attr)
- log.debug(_("Attributes %r are not yet available for entry %r") % (
- want_attrs,
- entry_dn
- ),
- level=8
- )
+ if len(want_attrs) > 0:
+ log.debug(_("Attributes %r are not yet available for entry %r") % (
+ want_attrs,
+ entry_dn
+ ),
+ level=8
+ )
+
# Also append the preferredlanguage or 'native tongue' configured
# for the entry.
if not entry.has_key('preferredlanguage'):
@@ -552,19 +554,14 @@ class LDAP(pykolab.base.Base):
# Primary mail address
if not primary_mail == None:
- if not entry.has_key(primary_mail_attribute) or \
- entry[primary_mail_attribute] == None:
-
- primary_mail_address = conf.plugins.exec_hook(
- "set_primary_mail",
- kw={
- 'primary_mail': primary_mail,
- 'entry': entry,
- 'primary_domain': self.domain
- }
- )
- else:
- primary_mail_address = entry[primary_mail_attribute]
+ primary_mail_address = conf.plugins.exec_hook(
+ "set_primary_mail",
+ kw={
+ 'primary_mail': primary_mail,
+ 'entry': entry,
+ 'primary_domain': self.domain
+ }
+ )
i = 1
_primary_mail = primary_mail_address
More information about the commits
mailing list