#NEWLINE# def process_response( self , request , response ) : #NEWLINE# #INDENT# 'Sets the cache, if needed.' #NEWLINE# if ( not self . _should_update_cache ( request , response ) ) : #NEWLINE# #INDENT# return response #NEWLINE# #UNINDENT# if ( not ( response . status_code == 200 ) ) : #NEWLINE# #INDENT# return response #NEWLINE# #UNINDENT# timeout = get_max_age ( response ) #NEWLINE# if ( timeout == None ) : #NEWLINE# #INDENT# timeout = self . cache_timeout #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request == 0 ) : #NEWLINE# #INDENT# return response #NEWLINE# #UNINDENT# #UNINDENT# patch_response_headers ( response , timeout ) #NEWLINE# if timeout : #NEWLINE# #INDENT# cache_key = learn_cache_key ( request , response , timeout , self . key_prefix , cache = self . cache ) #NEWLINE# if ( hasattr ( response , 'render' ) and callable ( response . render ) ) : #NEWLINE# #INDENT# response . add_post_render_callback ( ( lambda r : self . cache . set ( cache_key , r , timeout ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . cache . set ( cache_key , response , timeout ) #NEWLINE# #UNINDENT# #UNINDENT# return response