1.1 --- a/WebStack/Generic.py Fri Aug 27 23:51:02 2004 +0000
1.2 +++ b/WebStack/Generic.py Fri Aug 27 23:51:51 2004 +0000
1.3 @@ -19,9 +19,10 @@
1.4
1.5 "A container for content type information."
1.6
1.7 - def __init__(self, content_type, charset=None):
1.8 + def __init__(self, content_type, charset=None, attributes=None):
1.9 self.content_type = content_type
1.10 self.charset = charset
1.11 + self.attributes = attributes
1.12
1.13 class Transaction:
1.14
1.15 @@ -51,11 +52,22 @@
1.16 if content_type_field is None:
1.17 return ContentType(None, "iso-8859-1")
1.18
1.19 - t = content_type_field.split("; charset=")
1.20 - if len(t) == 1:
1.21 - return ContentType(t[0], "iso-8859-1")
1.22 - else:
1.23 - return ContentType(t[0], t[1])
1.24 + l = content_type_field.split(";")
1.25 + content_type_attributes = []
1.26 + content_type_charset = "iso-8859-1"
1.27 +
1.28 + # Find the charset and remember all other attributes.
1.29 +
1.30 + content_type_str, attributes = l[0].strip(), l[1:]
1.31 +
1.32 + for attribute in attributes:
1.33 + t = attribute.strip().split("=")
1.34 + if t[0] == "charset" and len(t) > 1:
1.35 + content_type_charset = t[1]
1.36 + else:
1.37 + content_type_attributes.append(t)
1.38 +
1.39 + return ContentType(content_type_str, content_type_charset, content_type_attributes)
1.40
1.41 def format_content_type(self, content_type):
1.42
1.43 @@ -242,7 +254,10 @@
1.44 the default encoding is to be overridden.
1.45
1.46 Returns a dictionary mapping field names to lists of values (even if a
1.47 - single value is associated with any given field name).
1.48 + single value is associated with any given field name). Each value is
1.49 + either a Unicode object (representing a simple form field, for example)
1.50 + or a file-like object (representing a file upload form field, for
1.51 + example).
1.52 """
1.53
1.54 raise NotImplementedError, "get_fields_from_body"