Call this to instantiate an instance or retrieve the existing instance. If the singleton requires args to be instantiated, include them the first time you call getInstance. Definition at line 78 of file singleton.py. : """ Call this to instantiate an instance or retrieve the existing instance. If the singleton requires args to be instantiated, include them the first time you call getInstance. """ if cls._isInstantiated(): if len(lstArgs) != 0: raise SingletonException, 'If no supplied args, singleton must already be instantiated, or __init__ must require no args' else: if len(lstArgs) != cls._getConstructionArgCountNotCountingSelf(): raise SingletonException, 'If the singleton requires __init__ args, supply them on first instantiation' instance = cls.__new__(cls) instance.__init__(*lstArgs) cls.cInstance = instance return cls.cInstance getInstance = classmethod(getInstance)
|