Mercurial > p > roundup > code
changeset 3499:230fb5d49c19
CSV encoding support [SF#1240848]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 25 Jan 2006 03:14:40 +0000 |
| parents | 8fcb2237a8ae |
| children | 950ce3afa6d3 |
| files | CHANGES.txt roundup/cgi/actions.py |
| diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Wed Jan 25 03:12:47 2006 +0000 +++ b/CHANGES.txt Wed Jan 25 03:14:40 2006 +0000 @@ -19,6 +19,7 @@ - classhelp works with Link properties now (sf bug 1410290) - added setorderprop() and setlabelprop() to Class (sf features 1379534, 1379490) +- CSV encoding support (sf bug 1240848) Fixed: - MySQL now creates String columns using the TEXT column type
--- a/roundup/cgi/actions.py Wed Jan 25 03:12:47 2006 +0000 +++ b/roundup/cgi/actions.py Wed Jan 25 03:14:40 2006 +0000 @@ -1,6 +1,6 @@ -#$Id: actions.py,v 1.54 2006-01-23 03:42:27 richard Exp $ +#$Id: actions.py,v 1.55 2006-01-25 03:14:40 richard Exp $ -import re, cgi, StringIO, urllib, Cookie, time, random, csv +import re, cgi, StringIO, urllib, Cookie, time, random, csv, codecs from roundup import hyperdb, token, date, password from roundup.i18n import _ @@ -961,7 +961,7 @@ matches = None h = self.client.additional_headers - h['Content-Type'] = 'text/csv' + h['Content-Type'] = 'text/csv; charset=%s' % self.client.charset # some browsers will honor the filename here... h['Content-Disposition'] = 'inline; filename=query.csv' @@ -971,7 +971,12 @@ # all done, return a dummy string return 'dummy' - writer = csv.writer(self.client.request.wfile) + wfile = self.client.request.wfile + if self.client.charset != self.client.STORAGE_CHARSET: + wfile = codecs.EncodedFile(wfile, + self.client.STORAGE_CHARSET, self.client.charset, 'replace') + + writer = csv.writer(wfile) writer.writerow(columns) # and search
