GoogleCloudPlatform / webapp2

webapp2 is a framework for Google App Engine
https://webapp2.readthedocs.org
Other
141 stars 63 forks source link

self.response.out.write(StateForm()) #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
With webapp, I can write out a form using self.response.out.write( form )

I can't with webapp-improved

    self.response.out.write(StateForm())
  File "/home/jamesd/python/google_appengine/lib/webob/webob/__init__.py", line 1613, in write
    self.body += text
TypeError: cannot concatenate 'str' and 'StateForm' objects

Original issue reported on code.google.com by JDeibele on 13 Aug 2010 at 6:12

GoogleCodeExporter commented 8 years ago
Hi, 
Thanks for the report. For now you can add this method to Response:

    def write(self, text):
        """Appends a text to the response body."""
        # webapp uses StringIO as Response.out, so we need to convert anything
        # that is not str or unicode to string to keep same StringIO behavior.
        if not isinstance(text, basestring):
            text = str(text)

        super(Response, self).write(text)

It'll be included in the next release.

Original comment by rodrigo.moraes on 13 Aug 2010 at 8:28

GoogleCodeExporter commented 8 years ago
This issue was closed by revision ac860e4927.

Original comment by rodrigo.moraes on 13 Aug 2010 at 8:45