pykolab/imap wallace/module_invitationpolicy.py

Thomas Brüderli bruederli at kolabsys.com
Mon Feb 2 19:11:17 CET 2015


 pykolab/imap/__init__.py           |   12 ++++--------
 wallace/module_invitationpolicy.py |    9 +++------
 2 files changed, 7 insertions(+), 14 deletions(-)

New commits:
commit 1e6d596fd0c9931a40a054c7294073a4c33a08de
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Feb 2 19:08:14 2015 +0100

    Fix pykolab.imap.namespaces function return and usage (#4277)

diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 4acc58f..356a3ff 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -319,21 +319,17 @@ class IMAP(object):
 
         _namespaces = re.split(r"\)\)\s\(\(", _namespaces)
 
-        _other_users = [
-                ''.join(_namespaces[1].replace('((','').replace('))','').split()[-1])
-            ]
-
         if len(_namespaces) >= 3:
             _shared = []
-            _shared.append(' '.join(_namespaces[2].replace('((','').replace('))','').split()[:-1]))
+            _shared.append(' '.join(_namespaces[2].replace('((','').replace('))','').split()[:-1]).replace('"', ''))
 
         if len(_namespaces) >= 2:
-            _other_users = ' '.join(_namespaces[1].replace('((','').replace('))','').split()[:-1])
+            _other_users = ' '.join(_namespaces[1].replace('((','').replace('))','').split()[:-1]).replace('"', '')
 
         if len(_namespaces) >= 1:
-            _personal = _namespaces[0].replace('((','').replace('))','').split()[0]
+            _personal = _namespaces[0].replace('((','').replace('))','').split()[0].replace('"', '')
 
-        return (_personal.replace('"', ''), _other_users.replace('"', ''), [x.replace('"', '') for x in _shared])
+        return (_personal, _other_users, _shared)
 
     def set_acl(self, folder, identifier, acl):
         """
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index 0a38fcc..6ffc5e5 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -727,15 +727,12 @@ def list_user_folders(user_rec, type):
 
     (ns_personal, ns_other, ns_shared) = imap.namespaces()
 
-    if isinstance(ns_shared, list):
-        ns_shared = ns_shared[0]
-    if isinstance(ns_other, list):
-        ns_other = ns_other[0]
-
     for folder in folders:
         # exclude shared and other user's namespace
         # TODO: list shared folders the user has write privileges ?
-        if folder.startswith(ns_other) or folder.startswith(ns_shared):
+        if not ns_other is None and folder.startswith(ns_other):
+            continue;
+        if not ns_shared is None and len([_ns for _ns in ns_shared if folder.startswith(_ns)]) > 0:
             continue;
 
         metadata = imap.get_metadata(folder)




More information about the commits mailing list