import csv


class MyDownloadHandler(webapp2.RequestHandler):

    def get(self):
        q = ModelName.gql("WHERE foo = 'bar' ORDER BY date ASC")
reqs = q.fetch(1000)
self.response.headers['Content-Type'] = 'text/csv'
self.response.headers['Content-Disposition'
    ] = 'attachment; filename=studenttransreqs.csv'
writer = csv.writer(self.response.out)
generating a CSV file online on Google App Engine