1.1 --- a/WebStack/Generic.py Fri Jun 20 22:21:30 2008 +0200
1.2 +++ b/WebStack/Generic.py Sun Feb 15 16:05:35 2004 +0000
1.3 @@ -102,6 +102,24 @@
1.4 accept_prefs.append(t[0].strip())
1.5 return accept_prefs
1.6
1.7 + def convert_to_list(self, value):
1.8 +
1.9 + """
1.10 + Returns a single element list containing 'value' if it is not itself a list, a
1.11 + tuple, or None. If 'value' is a list then it is itself returned; if 'value' is a
1.12 + tuple then a new list containing the same elements is returned; if 'value' is None
1.13 + then an empty list is returned.
1.14 + """
1.15 +
1.16 + if type(value) == type([]):
1.17 + return value
1.18 + elif type(value) == type(()):
1.19 + return list(value)
1.20 + elif value is None:
1.21 + return []
1.22 + else:
1.23 + return [value]
1.24 +
1.25 # Request-related methods.
1.26
1.27 def get_request_stream(self):
1.28 @@ -124,12 +142,21 @@
1.29 def get_headers(self):
1.30
1.31 """
1.32 - A framework-specific method which returns the request headers.
1.33 - NOTE: Experimental, since framework support varies somewhat.
1.34 + A framework-specific method which returns all request headers.
1.35 """
1.36
1.37 raise NotImplementedError, "get_headers"
1.38
1.39 + def get_header_values(self, key):
1.40 +
1.41 + """
1.42 + A framework-specific method which returns a list of all request header
1.43 + values associated with the given 'key'. Note that according to RFC 2616,
1.44 + 'key' is treated as a case-insensitive string.
1.45 + """
1.46 +
1.47 + raise NotImplementedError, "get_header_values"
1.48 +
1.49 def get_content_type(self):
1.50
1.51 """