#NEWLINE# def write_cache_decorator( self , node_or_pagetag , name , args , buffered , identifiers , inline = False , toplevel = False ) : #NEWLINE# #INDENT# 'write a post-function decorator to replace a rendering\n            callable with a cached version of itself.' #NEWLINE# self . printer . writeline ( ( '__M_%s = %s' % ( name , name ) ) ) #NEWLINE# cachekey = node_or_pagetag . parsed_attributes . get ( 'cache_key' , repr ( name ) ) #NEWLINE# cache_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . compiler . pagetag is not None ) : #NEWLINE# #INDENT# cache_args . update ( ( ( pa [ 6 : ] , self . compiler . pagetag . parsed_attributes [ pa ] ) for pa in self . compiler . pagetag . parsed_attributes if ( pa . startswith ( 'cache_' ) and ( pa != 'cache_key' ) ) ) ) #NEWLINE# #UNINDENT# cache_args . update ( ( ( pa [ 6 : ] , node_or_pagetag . parsed_attributes [ pa ] ) for pa in node_or_pagetag . parsed_attributes if ( pa . startswith ( 'cache_' ) and ( pa != 'cache_key' ) ) ) ) #NEWLINE# if ( 'timeout' in cache_args ) : #NEWLINE# #INDENT# cache_args [ 'timeout' ] = int ( eval ( cache_args [ 'timeout' ] ) ) #NEWLINE# #UNINDENT# self . printer . writeline ( ( 'def %s(%s):' % ( name , ',' . join ( args ) ) ) ) #NEWLINE# pass_args = [ ( ( ( '=' in a ) and ( '%s=%s' % ( ( a . split ( '=' ) [ 0 ] , ) * 2 ) ) ) or a ) for a in args ] #NEWLINE# self . write_variable_declares ( identifiers , toplevel = toplevel , limit = node_or_pagetag . undeclared_identifiers ( ) ) #NEWLINE# if buffered : #NEWLINE# #INDENT# s = ( "context.get('local').cache._ctx_get_or_create(%s, lambda:__M_%s(%s),  context, %s__M_defname=%r)" % ( cachekey , name , ',' . join ( pass_args ) , '' . join ( [ ( '%s=%s, ' % ( k , v ) ) for ( k , v ) in cache_args . items ( ) ] ) , name ) ) #NEWLINE# s = self . create_filter_callable ( self . compiler . buffer_filters , s , False ) #NEWLINE# self . printer . writelines ( ( 'return ' + s ) , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . printer . writelines ( ( "__M_writer(context.get('local').cache._ctx_get_or_create(%s, lambda:__M_%s(%s), context, %s__M_defname=%r))" % ( cachekey , name , ',' . join ( pass_args ) , '' . join ( [ ( '%s=%s, ' % ( k , v ) ) for ( k , v ) in cache_args . items ( ) ] ) , name ) ) , "return ''" , None )