I am working with TurboGears 2.2.2. and need to to serve a CSV file so that 
the user can download it.

This is the code that I have so far:


        response.content_type = 'text/csv'
        response.headers['Content-Disposition'] = 
'attachment;filename=%s.csv' % file_name

        listWriter = csv.writer(open(title+'.csv', 'wb'),
                        delimiter=',', quotechar='|', 
quoting=csv.QUOTE_MINIMAL)

        listWriter.writerow(['foo', 'bar'])

        with open (title+'.csv', "r") as myfile:
            response.body=myfile.read().replace('\n', '')

        return response


The CSV is created but I can't serve it to the user for download. I am 
always getting this error: "TypeError: No object (name: response) has been 
registered for this thread"

Any help, please?

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to