Package brisa :: Package core :: Module singleton
[hide private]
[frames] | no frames]

Source Code for Module brisa.core.singleton

 1  # Licensed under the MIT license 
 2  # http://opensource.org/licenses/mit-license.php or see LICENSE file. 
 3  # Copyright (C) 2007-2009 Renato 
 4  # Copyright 2007-2008 Brisa Team <brisa-develop@garage.maemo.org> 
 5   
 6  """ Provides a inheritable singleton class. 
 7  """ 
 8   
 9  __all__ = ('Singleton', ) 
10   
11   
12 -class SingletonType(type):
13
14 - def __call__(cls, *args, **kwargs):
15 if getattr(cls, '__instance__', None) is None: 16 instance = cls.__new__(cls) 17 instance.__init__(*args, **kwargs) 18 cls.__instance__ = instance 19 return cls.__instance__
20 21
22 -class Singleton(object):
23 __metaclass__ = SingletonType 24 pass
25