#NEWLINE# def instance( self , uri , cls = None , default = None , **kwargs ) : #NEWLINE# #INDENT# instance = self . _instances . get ( uri , None ) #NEWLINE# if ( instance is None ) : #NEWLINE# #INDENT# if ( cls is None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cls = self . _resources [ uri [ : uri . rfind ( '/' ) ] ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# cls = Reference #NEWLINE# #UNINDENT# #UNINDENT# if ( isinstance ( default , Resource ) and ( default . uri is None ) ) : #NEWLINE# #INDENT# default . _status = 200 #NEWLINE# default . _uri = uri #NEWLINE# instance = default #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# instance = cls ( uri = uri , ** kwargs ) #NEWLINE# #UNINDENT# self . _instances [ uri ] = instance #NEWLINE# #UNINDENT# return cls