diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2013-05-16 20:42:57 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2013-05-16 20:42:57 +0200 |
commit | a57e486f5739b4b374e428d43497909ad91fba2a (patch) | |
tree | b652d543dc3dfe397be27d6f17cc8b82b3b40ac3 | |
parent | 4f71ab2bb9587fca701cf5147ba5bdef1626b0b6 (diff) | |
download | pykolab-a57e486f5739b4b374e428d43497909ad91fba2a.tar.gz |
Catch the cases where a recipient policy fails
-rw-r--r-- | pykolab/plugins/recipientpolicy/__init__.py | 17 |
1 files changed, 14 insertions, 3 deletions
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 |