Branch 'pykolab-0.5' - 3 commits - pykolab/plugins pykolab/utils.py share/templates

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Thu Jan 10 16:52:59 CET 2013


 pykolab/plugins/recipientpolicy/__init__.py     |   19 ++++++++++++-------
 pykolab/utils.py                                |   11 ++++++++++-
 share/templates/roundcubemail/kolab.inc.php.tpl |    3 +++
 3 files changed, 25 insertions(+), 8 deletions(-)

New commits:
commit d68c3703b65b097f185a1e641efa0bc0dc010982
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jan 10 16:49:34 2013 +0100

    Make sure we transliterate the components before we push them in to a policy (#1508)

diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 9d50e83..e3d6b65 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -116,29 +116,34 @@ class KolabRecipientpolicy(object):
 
         alternative_mail = []
 
-        #print "%r" % (alternative_mail_routines)
+        log.debug(_("Alternative mail routines: %r") % (alternative_mail_routines), level=8)
         _domains = [ kw['primary_domain'] ] + kw['secondary_domains']
 
+        for attr in [ 'givenname', 'sn', 'surname' ]:
+            user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
+
         for number in alternative_mail_routines.keys():
             for routine in alternative_mail_routines[number].keys():
                 try:
                     exec("retval = '%s'.%s" % (routine,alternative_mail_routines[number][routine] % user_attrs))
+
+                    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"))
 
-                #log.debug(_("Appending additional mail address: %s") % (retval), level=8)
-                alternative_mail.append(utils.translate(retval, user_attrs['preferredlanguage']))
-
                 for _domain in kw['secondary_domains']:
                     user_attrs['domain'] = _domain
                     try:
                         exec("retval = '%s'.%s" % (routine,alternative_mail_routines[number][routine] % user_attrs))
+
+                        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"))
 
-                    #log.debug(_("Appending additional mail address: %s") % (retval), level=8)
-                    alternative_mail.append(utils.translate(retval, user_attrs['preferredlanguage']))
-
         alternative_mail = utils.normalize(alternative_mail)
 
         alternative_mail = list(set(alternative_mail))


commit 92f86d192411962c44e5c88338d314f9d35903e8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jan 10 16:47:22 2013 +0100

    Add debug statements for transliteration using pykolab.utils.translate(), so we can work out bugs such as #1508 and #1536

diff --git a/pykolab/utils.py b/pykolab/utils.py
index 78cdbf1..2ba5c89 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -23,9 +23,12 @@ import os
 import pwd
 import sys
 
+import pykolab
 from pykolab import constants
 from pykolab.translate import _
 
+log = pykolab.getLogger('pykolab.utils')
+
 def ask_question(question, default="", password=False, confirm=False):
     """
         Ask a question on stderr.
@@ -389,14 +392,19 @@ def translate(mystring, locale_name='en_US'):
     import locale
     import subprocess
 
+    log.debug(_("Transliterating string %r with locale %r") % (mystring, locale_name), level=8)
+
     if len(locale.normalize(locale_name).split('.')) > 1:
         (locale_name,locale_charset) = locale.normalize(locale_name).split('.')
     else:
         locale_charset = 'utf-8'
 
     try:
+        log.debug(_("Attempting to set locale"), level=8)
         locale.setlocale(locale.LC_ALL, (locale_name,locale_charset))
+        log.debug(_("Success setting locale"), level=8)
     except:
+        log.debug(_("Failure to set locale"), level=8)
         pass
 
     command = [ '/usr/bin/iconv',
@@ -404,9 +412,10 @@ def translate(mystring, locale_name='en_US'):
                 '-t', 'ASCII//TRANSLIT',
                 '-s' ]
 
+    log.debug(_("Executing '%s | %s'") % (r"%s" % (mystring), ' '.join(command)), level=8)
     process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, env={'LANG': locale.normalize(locale_name)})
 
-    print >> process.stdin, mystring
+    print >> process.stdin, r"%s" % mystring
 
     result = process.communicate()[0].strip()
 


commit f0119b59ec6e2cd98669908295d188273584d540
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jan 10 12:12:16 2013 +0000

    Add kolab_use_subscriptions setting to configuration template
    
    Conflicts:
    	share/templates/roundcubemail/kolab.inc.php.tpl

diff --git a/share/templates/roundcubemail/kolab.inc.php.tpl b/share/templates/roundcubemail/kolab.inc.php.tpl
index e8584a5..528f105 100644
--- a/share/templates/roundcubemail/kolab.inc.php.tpl
+++ b/share/templates/roundcubemail/kolab.inc.php.tpl
@@ -8,4 +8,7 @@
     \$rcmail_config['kolab_cache'] = true;
 
     \$rcmail_config['kolab_ssl_verify_peer'] = false;
+
+    \$rcmail_config['kolab_use_subscriptions'] = true;
+
 ?>





More information about the commits mailing list