HI group.  I'm using the python csv writer to drop a csv file
available for download/opening when a button is clicked on my site.
The code is shown here

      myselchecks=selchecks
      sql="select * from inquiries where inquiry_id = (%s)"
%myselchecks

      ctx.request.write_header('Content-Type', 'text/csv')
      ctx.request.write_header('Content-Disposition','attachment;
filename=contacts.csv')
      ctx.request.write = ctx.request.write_content
      writer = csv.writer(ctx.request)
      c = ctx.request.db.cursor()
      c.execute(sql)

      writer.writerow([x[0] for x in c.description])
      writer.writerows(c.fetchall())


This code drops all selected fields into a temporary csv file named
"contact.csv" so that it can be downloaded.  However, the template
HTML is being appended after the last record in the csv file.

Is there any way to prevent this from happening?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to