view.py
changeset 10211 59a77e8847bc
parent 10068 1b0cb3c6c95e
child 10609 e2d8e81bfe68
equal deleted inserted replaced
10210:633d85ba9f72 10211:59a77e8847bc
    18 """abstract views and templates classes for CubicWeb web client"""
    18 """abstract views and templates classes for CubicWeb web client"""
    19 
    19 
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 _ = unicode
    21 _ = unicode
    22 
    22 
    23 from cStringIO import StringIO
    23 from io import BytesIO
    24 from warnings import warn
    24 from warnings import warn
    25 from functools import partial
    25 from functools import partial
    26 
    26 
    27 from logilab.common.deprecation import deprecated
    27 from logilab.common.deprecation import deprecated
    28 from logilab.common.registry import yes
    28 from logilab.common.registry import yes
    99     def set_stream(self, w=None):
    99     def set_stream(self, w=None):
   100         if self.w is not None:
   100         if self.w is not None:
   101             return
   101             return
   102         if w is None:
   102         if w is None:
   103             if self.binary:
   103             if self.binary:
   104                 self._stream = stream = StringIO()
   104                 self._stream = stream = BytesIO()
   105             else:
   105             else:
   106                 self._stream = stream = UStringIO()
   106                 self._stream = stream = UStringIO()
   107             w = stream.write
   107             w = stream.write
   108         else:
   108         else:
   109             stream = None
   109             stream = None
   469     def set_stream(self, w=None):
   469     def set_stream(self, w=None):
   470         if self.w is not None:
   470         if self.w is not None:
   471             return
   471             return
   472         if w is None:
   472         if w is None:
   473             if self.binary:
   473             if self.binary:
   474                 self._stream = stream = StringIO()
   474                 self._stream = stream = BytesIO()
   475             else:
   475             else:
   476                 self._stream = stream = HTMLStream(self._cw)
   476                 self._stream = stream = HTMLStream(self._cw)
   477             w = stream.write
   477             w = stream.write
   478         else:
   478         else:
   479             stream = None
   479             stream = None