#NEWLINE# def _export_csv( self , return_url ) : #NEWLINE# #INDENT# '\n            Export a CSV of records as a stream.\n        ' #NEWLINE# ( count , data ) = self . _export_data ( ) #NEWLINE# class Echo ( object ) : #NEWLINE# #INDENT# '\n            An object that implements just the write method of the file-like\n            interface.\n            ' #NEWLINE# def write( self , value ) : #NEWLINE# #INDENT# '\n                Write the value by returning it, instead of storing\n                in a buffer.\n                ' #NEWLINE# return value #NEWLINE# #UNINDENT# #UNINDENT# writer = csv . writer ( Echo ( ) ) #NEWLINE# def generate( ) : #NEWLINE# #INDENT# titles = [ csv_encode ( c [ 1 ] ) for c in self . _export_columns ] #NEWLINE# ( yield writer . writerow ( titles ) ) #NEWLINE# for row in data : #NEWLINE# #INDENT# vals = [ csv_encode ( self . get_export_value ( row , c [ 0 ] ) ) for c in self . _export_columns ] #NEWLINE# ( yield writer . writerow ( vals ) ) #NEWLINE# #UNINDENT# #UNINDENT# filename = self . get_export_name ( export_type = 'csv' ) #NEWLINE# disposition = ( 'attachment;filename=%s' % ( secure_filename ( filename ) , ) ) #NEWLINE# return Response ( stream_with_context ( generate ( ) ) , headers = { #NEWLINE# #INDENT# 'Content-Disposition' : disposition , #NEWLINE# #UNINDENT# } , mimetype = 'text/csv' )