diff options
author | bbangert <devnull@localhost> | 2006-09-11 03:46:57 +0000 |
---|---|---|
committer | bbangert <devnull@localhost> | 2006-09-11 03:46:57 +0000 |
commit | 5131b9274d48704f7058a1facd141f933120124a (patch) | |
tree | 75a1494ba703fe16fd16f503312c34886e382ad0 /paste/wsgiwrappers.py | |
parent | 641d1d38fadedf49b2204af5b5ddeb225bb393ee (diff) | |
download | paste-5131b9274d48704f7058a1facd141f933120124a.tar.gz |
Added __call__ method to WSGIResponse object that conforms to WSGI spec.
Diffstat (limited to 'paste/wsgiwrappers.py')
-rw-r--r-- | paste/wsgiwrappers.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py index aab5415..33e01ca 100644 --- a/paste/wsgiwrappers.py +++ b/paste/wsgiwrappers.py @@ -165,6 +165,29 @@ class WSGIResponse(object): return '\n'.join(['%s: %s' % (key, value) for key, value in self.headers.headeritems()]) \ + '\n\n' + content + + def __call__(self, environ, start_response): + """Conveinence call to return output and set status information + + Conforms to the WSGI interface for calling purposes only. + + Example usage: + + .. code-block:: Python + def wsgi_app(environ, start_response): + response = WSGIResponse() + response.write("Hello world") + response.headers['Content-Type'] = 'latin1' + return response(environ, start_response) + + """ + status_text = STATUS_CODE_TEXT[self.status_code] + status = '%s %s' % (self.status_code, status_text) + response_headers = self.headers.headeritems() + for c in self.cookies.values(): + response_headers.append(('Set-Cookie', c.output(header=''))) + start_response(status, response_headers) + return self.get_content_as_string() def determine_encoding(self): """ |