class SingletonLoader(object):
cachedStates = {}
def __new__(cls, key, loadFunc):
print "SingletonLoader.new: cls = %s, key = %s, loadFunc = %s" % (cls, key, loadFunc)
if key not in cls.cachedStates:
plugin.msg("New key %s, invoking loader function %s" % (key, loadFunc))
cls.cachedStates[key] = loadFunc()
plugin.msg("Cached %s under key %s" % (key, cls.cachedStates[key]))
return super(SingletonLoader, cls).__new__(cls, key, loadFunc)
def __init__(self, key, loadFunc):
# Set members from the cached state matching the key.
self.__dict__ = self.__class__.cachedStates[key]
The line return super(SingletonLoad...... throws the error mentioned in the title.
Any idea why.