PEP 222 draft

Amos Latteier amos at
Thu Dec 28 02:23:42 CET 2000

Thanks Andrew for getting the ball rolling on CGI improvements!

I think that having request and response classes is a good idea.
Everyone else is doing it, why shouldn't we. Here are my comments:

Your request class looks reasonable. 

I have a couple issues with your response class. The response class has
no provisions for streaming. Also it probably won't work well with very
large responses since it seems to require that the entire response body
is set and retrieved as a string (via the setBody and __str__) methods.

I'd prefer something like

  def write(self, data):
      Write data to the body of the request. This method can be called
multiple times
      to stream output (assuming your web server supports streaming).
Call finish()
      when you've finished writing the body of the response. Note that
you must set
      the status and all headers and cookies before calling this method.

  def finish(self):
      "Call this method to signal that you've finished with the

We even might want to have a way to hand the response a file object to
represent the body. We also might want to let the user control buffering
of the response in some way, though I kind of doubt it.

Also I don't see the use of the '__str__' method on the response object.
In Zope this is used by ZPublisher to get the value of the response and
send it back to the web server. I'd rather have this handled internally
by the response. It would be triggered by a call to the 'finish' method.
If you need to see the response guts you already have the 'dump' method.
Also as I mentioned above the '__str__' method does not scale well to
very large responses.

Finally a nit, we probably want an 'addHeader' as well as a 'setHeader'
method since some headers can have multiple values.


Amos Latteier         mailto:amos at
Digital Creations

More information about the Python-list mailing list