[Web-SIG] Defining a standard interface for common web tasks

Bill Janssen janssen at parc.com
Fri Oct 24 17:59:11 EDT 2003


> res = web.cgi.HTTPResponse(sys.stdout)
> res.content_type = 'text/html'
> res.set_cookie('name', 'Simon')
> res[
> res.send_headers()
> res.write('

How about something like:

result = web.cgi.HTTPResponse(request)
result.set_content_type('text/html')
result.set_cookie('name', 'Simon')
result.set_header('X-Additional-Header', 'Another header')
result.write('<html><h1>Hi there</h1>\n%s' % body)')
...

I would assume that the 'result' instance would be auto-buffered and
flushed when necessary (or when the flush() method is called, just as
with file objects).

Bill



More information about the Web-SIG mailing list