mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Aliases to external addresses are now supported. Alias creation/modification forms have been rewritten. (autocompletion of addresses, dynamic number of input fields) see #143 First version of the postfixadmin to modoboa migration script. It has not been tested deeply but I think it should work pretty well. see #140 Some javascript errors (SqueezeBox related) have been fixed.
32 lines
948 B
Python
32 lines
948 B
Python
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:
|
|
cls.instances[key] = \
|
|
super(ConnectionsManager, cls).__call__(**kwargs)
|
|
else:
|
|
cls.instances[key].refresh(key, kwargs["password"])
|
|
return cls.instances[key]
|
|
|
|
class ConnectionError(Exception):
|
|
pass
|