# Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
# Distributed under the GPL v2
+ 12 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+ modules/catalyst/__init__.py:
+ Add base singleton class definition
+
12 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
modules/catalyst/lock.py:
More replacements of print statement with msg()
spawn = catalyst.spawn
target = catalyst.target
config = catalyst.config
+
+"""
+This class implements a proper singleton. This is useful for having a "global"
+var with config and spec values instead of passing them around between objects
+and functions
+"""
+class Singleton(object):
+
+ def __new__(type):
+ if not '_the_instance' in type.__dict__:
+ type._the_instance = object.__new__(type)
+ return type._the_instance
+