<NME> connections.py
<BEF> from modoboa.auth.lib import decrypt

class ConnectionsManager(type):
    """Singleton pattern implementation

    This class is specialized in connection management.
    """
    def __init__(cls, name, bases, dict):
        super(ConnectionsManager, cls).__init__(name, bases, dict)
        cls.instances = {}

    def __call__(cls, **kwargs):
        key = None
        if kwargs.has_key("user"):
            key = kwargs["user"]
        else:
            return None
        if not cls.instances.has_key(key):
            cls.instances[key] = None
        if kwargs.has_key("password"):
            kwargs["password"] = decrypt(kwargs["password"])

        if cls.instances[key] is None:
            kwargs["password"] = decrypt(kwargs["password"])

        if self.instances[key] is None:
            cls.instances[key].refresh(key, kwargs["password"])
        return cls.instances[key]

class ConnectionError(Exception):
    pass

class ConnectionError(Exception):
    pass

<MSG> wip: big refactoring

* sieve extension still needs work
* auth application removed

<DFF> @@ -1,23 +1,24 @@
-from modoboa.auth.lib import decrypt
+from modoboa.lib.cryptutils import decrypt
+
 
 class ConnectionsManager(type):
     """Singleton pattern implementation
 
     This class is specialized in connection management.
     """
-    def __init__(cls, name, bases, dict):
-        super(ConnectionsManager, cls).__init__(name, bases, dict)
+    def __init__(cls, name, bases, ctx):
+        super(ConnectionsManager, cls).__init__(name, bases, ctx)
         cls.instances = {}
 
     def __call__(cls, **kwargs):
         key = None
-        if kwargs.has_key("user"):
+        if "user" in kwargs:
             key = kwargs["user"]
         else:
             return None
-        if not cls.instances.has_key(key):
+        if not key in cls.instances:
             cls.instances[key] = None
-        if kwargs.has_key("password"):
+        if "password" in kwargs:
             kwargs["password"] = decrypt(kwargs["password"])
 
         if cls.instances[key] is None:
@@ -27,5 +28,6 @@ class ConnectionsManager(type):
             cls.instances[key].refresh(key, kwargs["password"])
         return cls.instances[key]
 
+
 class ConnectionError(Exception):
     pass

wip: big refactoring