[Python-checkins] CVS: python/dist/src/Lib cgi.py,1.49,1.50
Moshe Zadka
python-dev@python.org
Fri, 25 Aug 2000 14:47:58 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv8221/Lib
Modified Files:
cgi.py
Log Message:
Closing patch #101120 -- After everyone agreed.
Index: cgi.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** cgi.py 2000/08/03 20:57:44 1.49
--- cgi.py 2000/08/25 21:47:55 1.50
***************
*** 20,24 ****
#
! __version__ = "2.2"
--- 20,24 ----
#
! __version__ = "2.3"
***************
*** 32,35 ****
--- 32,36 ----
import mimetools
import rfc822
+ import UserDict
from StringIO import StringIO
***************
*** 167,175 ****
dict = {}
for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
! if len(value) or keep_blank_values:
! if dict.has_key(name):
! dict[name].append(value)
! else:
! dict[name] = [value]
return dict
--- 168,175 ----
dict = {}
for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
! if dict.has_key(name):
! dict[name].append(value)
! else:
! dict[name] = [value]
return dict
***************
*** 202,208 ****
raise ValueError, "bad query field: %s" % `name_value`
continue
! name = urllib.unquote(string.replace(nv[0], '+', ' '))
! value = urllib.unquote(string.replace(nv[1], '+', ' '))
! r.append((name, value))
return r
--- 202,209 ----
raise ValueError, "bad query field: %s" % `name_value`
continue
! if len(nv[1]) or keep_blank_values:
! name = urllib.unquote(string.replace(nv[0], '+', ' '))
! value = urllib.unquote(string.replace(nv[1], '+', ' '))
! r.append((name, value))
return r
***************
*** 538,541 ****
--- 539,553 ----
return found
+ def getvalue(self, key, default=None):
+ """Dictionary style get() method, including 'value' lookup."""
+ if self.has_key(key):
+ value = self[key]
+ if type(value) is type([]):
+ return map(lambda v: v.value, value)
+ else:
+ return value.value
+ else:
+ return default
+
def keys(self):
"""Dictionary style keys() method."""
***************
*** 707,711 ****
# ===============================
! class FormContentDict:
"""Basic (multiple values per field) form content as dictionary.
--- 719,723 ----
# ===============================
! class FormContentDict(UserDict.UserDict):
"""Basic (multiple values per field) form content as dictionary.
***************
*** 721,738 ****
"""
def __init__(self, environ=os.environ):
! self.dict = parse(environ=environ)
self.query_string = environ['QUERY_STRING']
- def __getitem__(self,key):
- return self.dict[key]
- def keys(self):
- return self.dict.keys()
- def has_key(self, key):
- return self.dict.has_key(key)
- def values(self):
- return self.dict.values()
- def items(self):
- return self.dict.items()
- def __len__( self ):
- return len(self.dict)
--- 733,738 ----
"""
def __init__(self, environ=os.environ):
! self.dict = self.data = parse(environ=environ)
self.query_string = environ['QUERY_STRING']