I have a singleton object that works perfectly from inside my main .py
file. However, when I want to access the object that backs the
singleton from another file ( either from an execfile() or thru my
telnet listener ), it appears the underlying object is reset to null,
resulting in a duplicate object being created.
I figure I am doing something painfully stupid, but for the life of me,
I can't see it.
Here is my singleton wrapper:
class SingletonWrappe r:
__instance = None
def __init__ ( self, user = None, password = None ):
if SingletonWrappe r.__instance is None:
SingletonWrappe r.__instance = ImplSingletonWr apper ( user, password )
def instance ( self ):
return SingletonWrappe r.__instance
In my ImplSingletonWr apper class, I print out that I am creating a new
object when its constructor is called. Inside the owner file, it is
only called once , but if I do SingletonWrappe r().instance() from
anohter module, it makes a new object, and id() reports different ids.
I banged my head against this yesterday, and today doesn't seem to be
going any better, any ideas out there?
--
ch***@acheris.n et | Fight Censorship, Boycott Wal-Mart
Now is the winter of your discontent! - Stewie