[wsgi] Convert "code" passed to WSGIResponse as integer
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 29 Nov 2017 16:14:57 +0100
changeset 12231 55924e962cd7
parent 12230 93dc77e9da77
child 12232 24393ce335f5
[wsgi] Convert "code" passed to WSGIResponse as integer WSGIResponse is passed a Request.status_out in CubicWebWSGIApplication._render(), which, starting from Python 3.5, is an instance of HTTPStatus. However, webtest still expects a 3-digits value as status string. Fortunately, calling int() on an HTTPStatus works.
cubicweb/wsgi/handler.py
--- a/cubicweb/wsgi/handler.py	Wed Nov 29 15:50:07 2017 +0100
+++ b/cubicweb/wsgi/handler.py	Wed Nov 29 16:14:57 2017 +0100
@@ -79,7 +79,7 @@
     """
     def __init__(self, code, req, body=None):
         text = STATUS_CODE_TEXT.get(code, 'UNKNOWN STATUS CODE')
-        self.status =  '%s %s' % (code, text)
+        self.status =  '%d %s' % (code, text)
         self.headers = list(chain(*[zip(repeat(k), v)
                                     for k, v in req.headers_out.getAllRawHeaders()]))
         self.headers = [(str(k), str(v)) for k, v in self.headers]