You may want to generate a .csv file using StringIO for downloading, here is how to do it in Turbogears 1.0.x:
@expose(content_type='text/csv',format="csv")
def csvdownload(self,**kw):
file = cStringIO.StringIO()
file.write('a,b,c\n')
cherrypy.response.headerMap["Content-Disposition"] ='attachment;filename=stats.csv'
return file.getvalue()
@expose(content_type='text/csv',format="csv")
def csvdownload(self,**kw):
file = cStringIO.StringIO()
file.write('a,b,c\n')
cherrypy.response.headerMap["Content-Disposition"] ='attachment;filename=stats.csv'
return file.getvalue()
Comments