#NEWLINE# @ _weak_decorator #NEWLINE# def __call__( classObj , * args , **kwargs ) : #NEWLINE# #INDENT# 'We will construct or look up an instance based on the\n           given arguments.\n\n           we return an instance of L{classObj} and track instance\n           with a weak reference so that we can manage memory. Note\n           by default objects will cache with a reference to self,\n           which will prevent gc from collecting the object. You\n           must state in the class data or instance constructor\n           that this object is ``reapable``.\n        ' #NEWLINE# instanceID = classObj . _safeID ( * args , ** kwargs ) #NEWLINE# if ( instanceID not in classObj . _instanceMap ) : #NEWLINE# #INDENT# classObj . _instanceMap [ instanceID ] = classObj . __new__ ( classObj , * args , ** kwargs ) #NEWLINE# classObj . _instanceMap [ instanceID ] . _instanceID = instanceID #NEWLINE# try : #NEWLINE# #INDENT# classObj . _instanceMap [ instanceID ] . __init__ ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# if ( instanceID in classObj . _instanceMap ) : #NEWLINE# #INDENT# del classObj . _instanceMap [ instanceID ] #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# return classObj . _instanceMap [ instanceID ]