[Web-SIG] Request/Response features

Ian Bicking ianb at colorstudy.com
Fri Oct 24 12:01:51 EDT 2003


On Friday, October 24, 2003, at 03:04 AM, David Fraser wrote:
>>> Some other comments:
>>> pathInfo/requestURI
>>>  would be good to have some consistency between these names
>>
>> They are mostly based off their CGI environment equivalent.
>
> OK, now I understand, but is this a good way to name things for the 
> future?

Pluses: CGI request variable names are being used by nearly every 
framework.  They are translatable from other languages, where they are 
also often used.  They are familiar and documented.  If we don't use 
CGI names, then we can't use the names at all, as it would be a bad 
false cognate to use (for instance) requestURI and extraPath.

Minuses: CGI variables don't have well standardized (or implemented) 
semantics.  IIS and Apache (at least) send slightly different things.  
But we can probably paper over those differences as they arise.

>>> getFieldDict
>>>  It would be great if the user could set the behaviour they want for 
>>> multiple keys.
>>>  I know I *always* want to discard any extra values. Including an 
>>> option to do this rather than return a list would prevent lots of 
>>> people doing post-processing
>>
>> That seems to difficult to define.  I don't think there should be 
>> customizations, because that makes it too difficult to work in a 
>> heterogeneous environment.  If you turn that setting on and some 
>> application you are using needs it off, then you get a configuration 
>> mess.  Wrappers could provide more friendly interfaces.
>
> If you defined a setField method as you said above, then people could 
> override it to throw away duplicate values. Maybe this is the way to > go

No, I retract my suggestion for setField ;)  This could be handled by a 
wrapper, like:

def getField(self, key):
     try:
         value = HTTPRequest.getField(self, key)
     except KeyError:
         value = HTTPRequest.getField(self, key + '[]')
         if not isinstance(value, list): return [value]
         return value
     if isinstance(value, list): return value[0]
     return value

This can be adapted to whatever equivalent of getField we use.

--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org




More information about the Web-SIG mailing list