Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 5418:55f09ca366c4
Python 3 preparation: StringIO.
This generally arranges for StringIO and cStringIO references to use
io.StringIO for Python 3 but io.BytesIO for Python 2, consistent with
the string representations generally used in Roundup. A special
FasterStringIO in the TAL code, which referenced internals of the old
Python 2 StringIO module, is cut down so it doesn't actually do
anything beyond the StringIO class it inherits from (it would also be
reasonable to remove FasterStringIO completely). One place in
roundup_server.py clearly needing binary I/O is made to use io.BytesIO
unconditionally.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Wed, 25 Jul 2018 09:08:29 +0000 |
| parents | 56c9bcdea47f |
| children | 58057ea53779 |
comparison
equal
deleted
inserted
replaced
| 5417:c749d6795bc2 | 5418:55f09ca366c4 |
|---|---|
| 27 | 27 |
| 28 from roundup.anypy import urllib_ | 28 from roundup.anypy import urllib_ |
| 29 from roundup import hyperdb, date, support | 29 from roundup import hyperdb, date, support |
| 30 from roundup import i18n | 30 from roundup import i18n |
| 31 from roundup.i18n import _ | 31 from roundup.i18n import _ |
| 32 from roundup.anypy.strings import is_us, us2s, s2u, u2s | 32 from roundup.anypy.strings import is_us, us2s, s2u, u2s, StringIO |
| 33 | 33 |
| 34 from .KeywordsExpr import render_keywords_expression_editor | 34 from .KeywordsExpr import render_keywords_expression_editor |
| 35 | 35 |
| 36 try: | 36 try: |
| 37 # Use the cryptographic source of randomness if available | 37 # Use the cryptographic source of randomness if available |
| 41 from random import random | 41 from random import random |
| 42 try: | 42 try: |
| 43 import cPickle as pickle | 43 import cPickle as pickle |
| 44 except ImportError: | 44 except ImportError: |
| 45 import pickle | 45 import pickle |
| 46 try: | |
| 47 import cStringIO as StringIO | |
| 48 except ImportError: | |
| 49 import StringIO | |
| 50 try: | 46 try: |
| 51 from StructuredText.StructuredText import HTML as StructuredText | 47 from StructuredText.StructuredText import HTML as StructuredText |
| 52 except ImportError: | 48 except ImportError: |
| 53 try: # older version | 49 try: # older version |
| 54 import StructuredText | 50 import StructuredText |
| 645 | 641 |
| 646 def csv(self): | 642 def csv(self): |
| 647 """ Return the items of this class as a chunk of CSV text. | 643 """ Return the items of this class as a chunk of CSV text. |
| 648 """ | 644 """ |
| 649 props = self.propnames() | 645 props = self.propnames() |
| 650 s = StringIO.StringIO() | 646 s = StringIO() |
| 651 writer = csv.writer(s) | 647 writer = csv.writer(s) |
| 652 writer.writerow(props) | 648 writer.writerow(props) |
| 653 check = self._client.db.security.hasPermission | 649 check = self._client.db.security.hasPermission |
| 654 userid = self._client.userid | 650 userid = self._client.userid |
| 655 if not check('Web Access', userid): | 651 if not check('Web Access', userid): |
