#NEWLINE# def write_render_callable( self , node , name , args , buffered , filtered , cached ) : #NEWLINE# #INDENT# 'write a top-level render callable.\n\n        this could be the main render() method or that of a top-level def.' #NEWLINE# if self . in_def : #NEWLINE# #INDENT# decorator = node . decorator #NEWLINE# if decorator : #NEWLINE# #INDENT# self . printer . writeline ( ( '@runtime._decorate_toplevel(%s)' % decorator ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . printer . writelines ( ( 'def %s(%s):' % ( name , ',' . join ( args ) ) ) , '__M_caller = context.caller_stack._push_frame()' , 'try:' ) #NEWLINE# if ( buffered or filtered or cached ) : #NEWLINE# #INDENT# self . printer . writeline ( 'context._push_buffer()' ) #NEWLINE# #UNINDENT# self . identifier_stack . append ( self . compiler . identifiers . branch ( self . node ) ) #NEWLINE# if ( ( ( not self . in_def ) or self . node . is_block ) and ( '**pageargs' in args ) ) : #NEWLINE# #INDENT# self . identifier_stack [ ( - 1 ) ] . argument_declared . add ( 'pageargs' ) #NEWLINE# #UNINDENT# if ( ( not self . in_def ) and ( ( len ( self . identifiers . locally_assigned ) > 0 ) or ( len ( self . identifiers . argument_declared ) > 0 ) ) ) : #NEWLINE# #INDENT# self . printer . writeline ( ( '__M_locals = __M_dict_builtin(%s)' % ',' . join ( [ ( '%s=%s' % ( x , x ) ) for x in self . identifiers . argument_declared ] ) ) ) #NEWLINE# #UNINDENT# self . write_variable_declares ( self . identifiers , toplevel = True ) #NEWLINE# for n in self . node . nodes : #NEWLINE# #INDENT# n . accept_visitor ( self ) #NEWLINE# #UNINDENT# self . write_def_finish ( self . node , buffered , filtered , cached ) #NEWLINE# self . printer . writeline ( None ) #NEWLINE# self . printer . write ( '\n\n' ) #NEWLINE# if cached : #NEWLINE# #INDENT# self . write_cache_decorator ( node , name , args , buffered , self . identifiers , toplevel = True )