summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-02 12:04:36 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-02 12:04:36 +0000
commitceb8643ec9ebff8925fbc5b1e5f734634e692c2a (patch)
tree62913b3953292f98a3307e46b3acdc6e8b086139
parent83c85dd54a7e1d29913dc525ca81823185b55e73 (diff)
downloadpykolab-ceb8643ec9ebff8925fbc5b1e5f734634e692c2a.tar.gz
Update recipientpolicy plugin by splitting the functions for primary mail and alternative mail addresses, so we can remove its inclusion of Auth() and Conf()
-rw-r--r--pykolab/plugin/recipientpolicy/__init__.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/pykolab/plugin/recipientpolicy/__init__.py b/pykolab/plugin/recipientpolicy/__init__.py
index e20548e..5f88a74 100644
--- a/pykolab/plugin/recipientpolicy/__init__.py
+++ b/pykolab/plugin/recipientpolicy/__init__.py
@@ -24,38 +24,40 @@ class KolabRecipientpolicy(object):
Example plugin making quota adjustments given arbitrary conditions.
"""
- def __init__(self):
- pass
+ def __init__(self, conf=None):
+ self.conf = conf
- def set_user_attrs(self, kw={}, args=()):
+ def set_user_attrs_mail(self, kw={}, args=()):
"""
- The arguments passed to the 'set_user_folder_quota' hook:
+ The arguments passed to the 'set_user_attrs_mail' hook:
- - used (integer, in KB)
- - current quota (integer, in KB)
- - quota (integer, in KB)
+ - current user attributes
"""
-
(user_attrs) = args
+ mail = self.conf.get_raw('recipient_policy', 'primary_email') % self.normalize(user_attrs)
+ return mail
+
+ def set_user_attrs_alternative_mail(self, kw={}, args=()):
+ """
+ The arguments passed to the 'set_user_attrs_alternative_mail' hook:
+
+ - current user attributes
+ """
- auth = Auth()
+ (user_attrs) = args
- user_attrs['mail'] = auth.conf.get_raw('recipient_policy', 'primary_email') % self.normalize(user_attrs)
- other_email_routines = auth.conf.get_raw('recipient_policy', 'other_email')
+ mail = self.conf.get_raw('recipient_policy', 'primary_email') % self.normalize(user_attrs)
+ other_email_routines = self.conf.get_raw('recipient_policy', 'other_email')
exec("other_email_routines = %s" % other_email_routines)
- other_email = []
+ alternative_email = []
for routine in other_email_routines.keys():
exec("retval = '%s'.%s" % (routine,other_email_routines[routine] % self.normalize(user_attrs)))
- other_email.append(retval)
-
- print other_email
+ alternative_email.append(retval)
- auth.set_user_attribute(user_attrs['dn'], 'mail', user_attrs['mail'])
-
- return user_attrs
+ return alternative_email
def normalize(self, user_attrs):
if user_attrs.has_key('sn'):
@@ -65,4 +67,4 @@ class KolabRecipientpolicy(object):
if len(user_attrs['mail'].split('@')) > 1:
user_attrs['domain'] = user_attrs['mail'].split('@')[1]
- return user_attrs \ No newline at end of file
+ return user_attrs