Files
modoboa/modoboa/lib/singleton.py
T
Antoine Nguyen f91ef1adf2 wip: relay domains support
* Unit tests added (limits application)
* Added support for limits
* Big changes were required
* Using standard HTTP codes to identify errors (json)
* Custom exceptions have been reworked (not finished yet)

see #491
2013-10-28 18:36:42 +01:00

16 lines
357 B
Python

# works in Python 2 & 3
class _Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = \
super(_Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
class Singleton(_Singleton('SingletonMeta', (object,), {})):
pass