#NEWLINE# @ classmethod #NEWLINE# def get( cls , obj_or_name , save = True ) : #NEWLINE# #INDENT# 'Returns a System instance representing this object.' #NEWLINE# if isinstance ( obj_or_name , cls ) : #NEWLINE# #INDENT# return obj_or_name #NEWLINE# #UNINDENT# if isinstance ( obj_or_name , basestring ) : #NEWLINE# #INDENT# return _get_or_create ( cls , name = obj_or_name ) #NEWLINE# #UNINDENT# obj = obj_or_name #NEWLINE# if ( not isinstance ( obj , models . Model ) ) : #NEWLINE# #INDENT# raise TypeError ( 'This classmethod only supports get Systems for model objects.' ) #NEWLINE# #UNINDENT# if ( not obj . pk ) : #NEWLINE# #INDENT# raise ValueError ( 'Model object has no primary key.' ) #NEWLINE# #UNINDENT# ct = ContentType . objects . get_for_model ( obj . __class__ ) #NEWLINE# try : #NEWLINE# #INDENT# obj = cls . objects . get ( content_type = ct , object_id = obj . pk ) #NEWLINE# #UNINDENT# except cls . DoesNotExist : #NEWLINE# #INDENT# obj = cls ( content_type = ct , object_id = obj . pk ) #NEWLINE# if cls : #NEWLINE# #INDENT# obj . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# return obj