Branch 'pykolab-0.5' - 7 commits - pykolab/auth pykolab/plugins pykolab/utils.py
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Thu May 16 20:45:16 CEST 2013
pykolab/auth/ldap/__init__.py | 24 +++++++++++++++++++++++-
pykolab/plugins/recipientpolicy/__init__.py | 24 ++++++++++++++++++------
pykolab/utils.py | 3 +++
3 files changed, 44 insertions(+), 7 deletions(-)
New commits:
commit f9598d9d10360699f9c295ec6febe4d005663721
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 20:43:18 2013 +0200
pykolab/utils really cannot deal with a list of primary mail attribute values
diff --git a/pykolab/utils.py b/pykolab/utils.py
index 57617a7..f018f78 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -292,6 +292,9 @@ def normalize(_object):
result['surname'] = result['sn'].replace(' ', '')
if result.has_key('mail'):
+ if isinstance(result['mail'], list):
+ result['mail'] = result['mail'][0]
+
if len(result['mail']) > 0:
if len(result['mail'].split('@')) > 1:
result['domain'] = result['mail'].split('@')[1]
commit a57e486f5739b4b374e428d43497909ad91fba2a
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 20:42:57 2013 +0200
Catch the cases where a recipient policy fails
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index f9949de..ff3143a 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -121,7 +121,14 @@ class KolabRecipientpolicy(object):
_domains = [ kw['primary_domain'] ] + kw['secondary_domains']
for attr in [ 'givenname', 'sn', 'surname' ]:
- user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
+ try:
+ user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
+ except Exception, errmsg:
+ log.error(_("An error occurred in composing the secondary mail attribute for entry %r") % (user_attrs['id']))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
+ return []
for number in alternative_mail_routines.keys():
for routine in alternative_mail_routines[number].keys():
@@ -131,8 +138,12 @@ class KolabRecipientpolicy(object):
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
- except KeyError, e:
- log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
+ except Exception, errmsg:
+ log.error(_("Policy for secondary email address failed: %r") % (errmsg))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
+ return []
for _domain in kw['secondary_domains']:
user_attrs['domain'] = _domain
commit 4f71ab2bb9587fca701cf5147ba5bdef1626b0b6
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 20:42:17 2013 +0200
Be a little more verbose about what exactly goes wrong when we catch the exception
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 5037709..413ebf8 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -2190,7 +2190,11 @@ class LDAP(pykolab.base.Base):
break
- except:
+ except Exception, errmsg:
+ log.error(_("An error occured using %s: %r") % (supported_control, errmsg))
+ if conf.debuglevel > 8:
+ import traceback
+ traceback.print_exc()
continue
return _results
commit 944a395dc2f00cca7e47b506b7c1224657ccc557
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 20:00:37 2013 +0200
Return user_attrs['mail'], which exists, while mail is not set
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 59146c1..f9949de 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -78,7 +78,7 @@ class KolabRecipientpolicy(object):
except KeyError, e:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
if user_attrs.has_key('mail'):
- return mail
+ return user_attrs['mail']
else:
return None
commit 3a209a1668221e4e2cba904e26eee991a3bf021a
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 19:44:43 2013 +0200
Make sure a non-existent result attribute value does not result in an attempt to create a mailbox
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index d1c2642..5037709 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1088,6 +1088,9 @@ class LDAP(pykolab.base.Base):
if entry[result_attribute] == None:
return
+ if entry[result_attribute] == '':
+ return
+
cache.get_entry(self.domain, entry)
self.imap.connect(domain=self.domain)
@@ -1220,6 +1223,15 @@ class LDAP(pykolab.base.Base):
for key in entry_changes.keys():
entry[key] = entry_changes[key]
+ if not entry.has_key(result_attribute):
+ return
+
+ if entry[result_attribute] == None:
+ return
+
+ if entry[result_attribute] == '':
+ return
+
# Now look at entry_changes and old_canon_attr, and see if they're
# the same value.
if entry_changes.has_key(result_attribute):
commit ff1aa0f1e2fa7cd7c33eb5d7f046f548da9e69da
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 19:41:29 2013 +0200
Make sure a failing recipient policy does not result in a blocked process (#1878)
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 93cfc19..d1c2642 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -567,6 +567,9 @@ class LDAP(pykolab.base.Base):
}
)
+ if primary_mail_address == None:
+ return entry_modifications
+
i = 1
_primary_mail = primary_mail_address
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index e3d6b65..59146c1 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -77,9 +77,10 @@ class KolabRecipientpolicy(object):
return mail
except KeyError, e:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
- mail = utils.translate(user_attrs['mail'], user_attrs['preferredlanguage'])
- mail = mail.lower()
- return mail
+ if user_attrs.has_key('mail'):
+ return mail
+ else:
+ return None
def set_secondary_mail(self, *args, **kw):
"""
commit 9877c353bb00d9a1eeae7bafe51c727836a0d921
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Thu May 16 19:47:50 2013 +0200
Return if the entry result attribute is empty or does not exist
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index b168262..93cfc19 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1397,6 +1397,9 @@ class LDAP(pykolab.base.Base):
entry[key] = entry_changes[key]
self.set_entry_attribute(entry, key, entry[key])
+ if not entry.has_key(result_attribute) or entry[result_attribute] == None:
+ return
+
cache.get_entry(self.domain, entry)
self.imap.connect(domain=self.domain)
More information about the commits
mailing list