[Web-SIG] Pre-PEP: Python Web Container Interface v1.0
Phillip J. Eby
pje at telecommunity.com
Mon Dec 8 10:29:40 EST 2003
At 06:38 AM 12/8/03 -0500, A.M. Kuchling wrote:
>On Sun, Dec 07, 2003 at 07:05:26PM -0500, Phillip J. Eby wrote:
> > Maybe I'm overreacting to being burned by imperfect dictionary simulations
> > in the past. OTOH, I noticed you haven't actually given a use case for
> > *not* using a dictionary. :)
>os.environ is not a dictionary (nor a subclass of dict), so the simplest CGI
>case would be runCGI(sys.stdin, sys.stdout, sys.stderr, os.environ.copy()).
The copy() in that case would arguably be necessary anyway. Remember that
the spec requires the caller to be allowed to *modify* environ in place.
Anyway, as per my response to Stuart, I suppose I could further compromise
to having the spec require that the copy() method return a
dictionary. Then people who want to be sure their manipulations are
portable, can simply take a copy of environ. (Or, alternatively, .items()
could be required, and the portable mechanism would be to use
But, given how simple it is for the container to use a dictionary in the
first place, it seems silly to force every layer to do a copy "just in
case" to be portable. And, I think that os.environ really is the exception
rather than the rule. How many existing containers use non-dictionaries now?
More information about the Web-SIG