1.1 --- a/WebStack/Zope.py Thu Sep 02 19:31:31 2004 +0000
1.2 +++ b/WebStack/Zope.py Thu Sep 02 19:32:22 2004 +0000
1.3 @@ -11,6 +11,7 @@
1.4 from Helpers.Request import Cookie, get_body_field
1.5 from Helpers.Response import ConvertingStream
1.6 from ZPublisher.HTTPRequest import FileUpload
1.7 +import cgi
1.8
1.9 class Transaction(Generic.Transaction):
1.10
1.11 @@ -158,13 +159,7 @@
1.12 single value is associated with any given field name).
1.13 """
1.14
1.15 - fields = {}
1.16 - for key, value in self.request.form.items():
1.17 - if type(value) == type([]):
1.18 - fields[key] = value
1.19 - else:
1.20 - fields[key] = [value]
1.21 - return fields
1.22 + return cgi.parse_qs(self.get_query_string())
1.23
1.24 def get_fields_from_body(self, encoding=None):
1.25
1.26 @@ -179,20 +174,44 @@
1.27 either a Unicode object (representing a simple form field, for example)
1.28 or a plain string (representing a file upload form field, for example).
1.29
1.30 - NOTE: Zope doesn't distinguish between path and body fields.
1.31 + NOTE: This still does not seem to work with UTF-16.
1.32 """
1.33
1.34 - # NOTE: Conversion to Unicode may be inappropriate.
1.35 + # Fix the inclusion of path fields since this prevents Unicode conversion.
1.36 +
1.37 + fields_from_path = self.get_fields_from_path()
1.38
1.39 encoding = encoding or self.get_content_type().charset or self.default_charset
1.40 fields = {}
1.41 - for field_name, field_values in self.get_fields_from_path().items():
1.42 + for field_name, field_values in self.request.form.items():
1.43 +
1.44 + # Find the path values for this field (for filtering below).
1.45 +
1.46 + if fields_from_path.has_key(field_name):
1.47 + field_from_path_values = fields_from_path[field_name]
1.48 + if type(field_from_path_values) != type([]):
1.49 + field_from_path_values = [field_from_path_values]
1.50 + else:
1.51 + field_from_path_values = []
1.52 +
1.53 + # Find the body values.
1.54 +
1.55 if type(field_values) == type([]):
1.56 fields[field_name] = []
1.57 for field_str in field_values:
1.58 - fields[field_name].append(get_body_field(field_str, encoding))
1.59 + # Filter path values.
1.60 + if field_str not in field_from_path_values:
1.61 + fields[field_name].append(get_body_field(field_str, encoding))
1.62 +
1.63 + # Remove filtered fields.
1.64 +
1.65 + if fields[field_name] == []:
1.66 + del fields[field_name]
1.67 else:
1.68 - fields[field_name] = [get_body_field(field_values, encoding)]
1.69 + # Filter path values.
1.70 + if field_values not in field_from_path_values:
1.71 + fields[field_name] = [get_body_field(field_values, encoding)]
1.72 +
1.73 return fields
1.74
1.75 def get_user(self):