#NEWLINE# @ staticmethod #NEWLINE# def get_by_id_safe( id , user = None ) : #NEWLINE# #INDENT# mem_key = ( 'monster:%s' % id ) #NEWLINE# result = memcache . get ( mem_key ) #NEWLINE# if ( not result ) : #NEWLINE# #INDENT# result = Monster . get_by_id ( id ) #NEWLINE# #UNINDENT# if ( not result ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# memcache . add ( mem_key , result ) #NEWLINE# #UNINDENT# if ( user and ( result . product in user . products ) ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( result . product == ( - 1 ) ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# #UNINDENT# return None