Mercurial > p > roundup > code
comparison roundup/cgi/actions.py @ 6083:f74d078cfd9a
issue2551019 needs to be handled in the action code itself, not the WSGI handler
for Python 3 we always need to encode the output in the client character set
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Sat, 08 Feb 2020 00:29:13 +0000 |
| parents | b011e5ac06d5 |
| children | 15fd91fd3c4c |
comparison
equal
deleted
inserted
replaced
| 6082:a3221c686736 | 6083:f74d078cfd9a |
|---|---|
| 1 import re, cgi, time, csv, codecs | 1 import re, cgi, time, csv, codecs, sys |
| 2 | 2 |
| 3 from roundup import hyperdb, token, date, password | 3 from roundup import hyperdb, token, date, password |
| 4 from roundup.actions import Action as BaseAction | 4 from roundup.actions import Action as BaseAction |
| 5 from roundup.i18n import _ | 5 from roundup.i18n import _ |
| 6 from roundup.cgi import exceptions, templating | 6 from roundup.cgi import exceptions, templating |
| 1429 if self.client.env['REQUEST_METHOD'] == 'HEAD': | 1429 if self.client.env['REQUEST_METHOD'] == 'HEAD': |
| 1430 # all done, return a dummy string | 1430 # all done, return a dummy string |
| 1431 return 'dummy' | 1431 return 'dummy' |
| 1432 | 1432 |
| 1433 wfile = self.client.request.wfile | 1433 wfile = self.client.request.wfile |
| 1434 if self.client.charset != self.client.STORAGE_CHARSET: | 1434 if sys.version_info[0] > 2: |
| 1435 wfile = codecs.getwriter(self.client.charset)(wfile, 'replace') | |
| 1436 elif self.client.charset != self.client.STORAGE_CHARSET: | |
| 1435 wfile = codecs.EncodedFile(wfile, | 1437 wfile = codecs.EncodedFile(wfile, |
| 1436 self.client.STORAGE_CHARSET, | 1438 self.client.STORAGE_CHARSET, |
| 1437 self.client.charset, 'replace') | 1439 self.client.charset, 'replace') |
| 1438 | 1440 |
| 1439 writer = csv.writer(wfile) | 1441 writer = csv.writer(wfile) |
| 1592 if self.client.env['REQUEST_METHOD'] == 'HEAD': | 1594 if self.client.env['REQUEST_METHOD'] == 'HEAD': |
| 1593 # all done, return a dummy string | 1595 # all done, return a dummy string |
| 1594 return 'dummy' | 1596 return 'dummy' |
| 1595 | 1597 |
| 1596 wfile = self.client.request.wfile | 1598 wfile = self.client.request.wfile |
| 1597 if self.client.charset != self.client.STORAGE_CHARSET: | 1599 if sys.version_info[0] > 2: |
| 1600 wfile = codecs.getwriter(self.client.charset)(wfile, 'replace') | |
| 1601 elif self.client.charset != self.client.STORAGE_CHARSET: | |
| 1598 wfile = codecs.EncodedFile(wfile, | 1602 wfile = codecs.EncodedFile(wfile, |
| 1599 self.client.STORAGE_CHARSET, | 1603 self.client.STORAGE_CHARSET, |
| 1600 self.client.charset, 'replace') | 1604 self.client.charset, 'replace') |
| 1601 | 1605 |
| 1602 writer = csv.writer(wfile) | 1606 writer = csv.writer(wfile) |
