# HG changeset patch # User paulb # Date 1094506264 0 # Node ID e08429cda6d39f1e4fd5232523576a882be2cb3a # Parent 861474231d554b6ea8e80eb1fa57262a58e6398b [project @ 2004-09-06 21:31:04 by paulb] Added get_fields and made the existing field access methods more strict about which values are associated with each information source (path and request body). diff -r 861474231d55 -r e08429cda6d3 WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Mon Sep 06 21:31:04 2004 +0000 @@ -200,23 +200,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return parse_qs(self.get_query_string(), keep_blank_values=1) + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -242,6 +249,36 @@ return fields + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + # Combine the two sources. + + fields = {} + fields.update(self.get_fields_from_path()) + for name, values in self.get_fields_from_body(encoding).items(): + if not fields.has_key(name): + fields[name] = values + else: + fields[name] += values + return fields + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/CGI.py --- a/WebStack/CGI.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/CGI.py Mon Sep 06 21:31:04 2004 +0000 @@ -192,23 +192,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return parse_qs(self.get_query_string(), keep_blank_values=1) + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -219,7 +226,10 @@ encoding = encoding or self.get_content_type().charset or self.default_charset if self.storage_body is None: - self.storage_body = FieldStorage(fp=self.get_request_stream(), keep_blank_values=1) + self.storage_body = FieldStorage(fp=self.get_request_stream(), + headers={"content-type" : str(self.get_content_type())}, + environ={"REQUEST_METHOD" : self.get_request_method()}, + keep_blank_values=1) # Avoid strange design issues with FieldStorage by checking the internal # field list directly. @@ -233,6 +243,36 @@ return fields + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + # Combine the two sources. + + fields = {} + fields.update(self.get_fields_from_path()) + for name, values in self.get_fields_from_body(encoding).items(): + if not fields.has_key(name): + fields[name] = values + else: + fields[name] += values + return fields + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/Generic.py --- a/WebStack/Generic.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/Generic.py Mon Sep 06 21:31:04 2004 +0000 @@ -281,9 +281,9 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -294,10 +294,10 @@ def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -307,6 +307,27 @@ raise NotImplementedError, "get_fields_from_body" + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + raise NotImplementedError, "get_fields" + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/JavaServlet.py --- a/WebStack/JavaServlet.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/JavaServlet.py Mon Sep 06 21:31:04 2004 +0000 @@ -6,7 +6,7 @@ import Generic from StringIO import StringIO -from Helpers.Request import Cookie, get_body_fields, get_storage_items, get_fields_from_query_string +from Helpers.Request import Cookie, get_body_fields, get_storage_items, get_fields_from_query_string, filter_fields import javax.servlet.http # Form data decoding. @@ -45,7 +45,11 @@ "Read a line from the stream, returning it as a string." - return self.stream.readLine() + "\n" + line = self.stream.readLine() + if line is not None: + return line + "\n" + else: + return "" class Transaction(Generic.Transaction): @@ -75,7 +79,7 @@ # Cached information. - self.storage_body = None + self.message_fields = None def commit(self): @@ -221,9 +225,9 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -239,10 +243,10 @@ def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -250,6 +254,16 @@ or a plain string (representing a file upload form field, for example). """ + # There may not be a reliable means of extracting only the fields + # the message body using the API. Remove fields originating from the + # path in the mixture provided by the API. + + all_fields = self._get_fields(encoding) + fields_from_path = self.get_fields_from_path() + return filter_fields(all_fields, fields_from_path) + + def _get_fields(self, encoding=None): + # Override the default encoding if requested. if encoding is not None: @@ -260,41 +274,51 @@ # methods. if self.get_content_type() and self.get_content_type().media_type == "multipart/form-data": - fields = self._get_fields_from_message() - + if self.message_fields is not None: + return self.message_fields + else: + fields = self.message_fields = self._get_fields_from_message() else: - # There may not be a reliable means of extracting only the fields - # the message body using the API. Remove fields originating from the - # path in the mixture provided by the API. - - fields_from_path = self.get_fields_from_path() - fields = {} parameter_map = self.request.getParameterMap() if parameter_map: for field_name in parameter_map.keySet(): + fields[field_name] = parameter_map[field_name] - # Find path values for this field. + return fields + + def get_fields(self, encoding=None): - if fields_from_path.has_key(field_name): - field_from_path_values = fields_from_path[field_name] - if type(field_from_path_values) != type([]): - field_from_path_values = [field_from_path_values] - else: - field_from_path_values = [] + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). - # Filter out path values. + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + # NOTE: The Java Servlet API (like Zope) seems to provide only body + # NOTE: fields upon POST requests. - fields[field_name] = [] - for field_value in parameter_map[field_name]: - if field_value not in field_from_path_values: - fields[field_name].append(field_value) - - # Remove filtered entries. - - if fields[field_name] == []: - del fields[field_name] - + if self.get_request_method() == "GET": + return self._get_fields(encoding) + else: + fields = {} + fields.update(self.get_fields_from_path()) + for name, values in self._get_fields(encoding).items(): + if not fields.has_key(name): + fields[name] = values + else: + fields[name] += values return fields def get_user(self): diff -r 861474231d55 -r e08429cda6d3 WebStack/ModPython.py --- a/WebStack/ModPython.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/ModPython.py Mon Sep 06 21:31:04 2004 +0000 @@ -5,7 +5,7 @@ """ import Generic -from Helpers.Request import get_body_field +from Helpers.Request import get_body_field, filter_fields from Helpers.Response import ConvertingStream from mod_python.util import parse_qs, FieldStorage from mod_python import apache @@ -175,23 +175,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return parse_qs(self.get_query_string(), 1) # keep_blank_values=1 + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in parse_qs(self.get_query_string(), 1).items(): # keep_blank_values=1 + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -202,6 +209,11 @@ body with fields found in the path. """ + all_fields = self._get_fields(encoding) + fields_from_path = self.get_fields_from_path() + return filter_fields(all_fields, fields_from_path) + + def _get_fields(self, encoding=None): encoding = encoding or self.get_content_type().charset or self.default_charset if self.storage_body is None: @@ -216,6 +228,27 @@ fields[field.name].append(get_body_field(field.value, encoding)) return fields + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + return self._get_fields(encoding) + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/Twisted.py --- a/WebStack/Twisted.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/Twisted.py Mon Sep 06 21:31:04 2004 +0000 @@ -6,7 +6,7 @@ import Generic from Helpers.Auth import UserInfo -from Helpers.Request import Cookie, get_body_field +from Helpers.Request import Cookie, get_body_field, filter_fields from Helpers.Response import ConvertingStream from Helpers.Session import SessionStore from cgi import parse_qs @@ -154,23 +154,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return parse_qs(self.get_query_string(), keep_blank_values=1) + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -178,23 +185,19 @@ or a plain string (representing a file upload form field, for example). """ - # Fix the inclusion of path fields since this prevents Unicode conversion. + # There may not be a reliable means of extracting only the fields + # the message body using the API. Remove fields originating from the + # path in the mixture provided by the API. + all_fields = self._get_fields(encoding) fields_from_path = self.get_fields_from_path() + return filter_fields(all_fields, fields_from_path) + def _get_fields(self, encoding=None): encoding = encoding or self.get_content_type().charset or self.default_charset fields = {} for field_name, field_values in self.trans.args.items(): - # Find the path values for this field (for filtering below). - - if fields_from_path.has_key(field_name): - field_from_path_values = fields_from_path[field_name] - if type(field_from_path_values) != type([]): - field_from_path_values = [field_from_path_values] - else: - field_from_path_values = [] - # Find the body values. if type(field_values) == type([]): @@ -203,21 +206,33 @@ # Twisted stores plain strings. for field_str in field_values: - # Filter path values. - if field_str not in field_from_path_values: - fields[field_name].append(get_body_field(field_str, encoding)) - - # Remove filtered fields. - - if fields[field_name] == []: - del fields[field_name] + fields[field_name].append(get_body_field(field_str, encoding)) else: - # Filter path values. - if field_values not in field_from_path_values: - fields[field_name] = get_body_field(field_values, encoding) + fields[field_name] = get_body_field(field_values, encoding) return fields + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + return self._get_fields(encoding) + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/Webware.py --- a/WebStack/Webware.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/Webware.py Mon Sep 06 21:31:04 2004 +0000 @@ -8,7 +8,7 @@ from cgi import parse_qs import StringIO from Helpers import Environment -from Helpers.Request import Cookie, get_body_field +from Helpers.Request import Cookie, get_body_field, filter_fields from Helpers.Response import ConvertingStream class Transaction(Generic.Transaction): @@ -158,23 +158,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return parse_qs(self.get_query_string(), keep_blank_values=1) + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in parse_qs(self.get_query_string(), keep_blank_values=1).items(): + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -182,6 +189,11 @@ or a plain string (representing a file upload form field, for example). """ + all_fields = self._get_fields(encoding) + fields_from_path = self.get_fields_from_path() + return filter_fields(all_fields, fields_from_path) + + def _get_fields(self, encoding=None): encoding = encoding or self.get_content_type().charset or self.default_charset fields = {} for field_name, field_values in self.trans.request().fields().items(): @@ -193,6 +205,27 @@ fields[field_name] = [get_body_field(field_values, encoding)] return fields + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. + + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + + return self._get_fields(encoding) + def get_user(self): """ diff -r 861474231d55 -r e08429cda6d3 WebStack/Zope.py --- a/WebStack/Zope.py Mon Sep 06 21:29:59 2004 +0000 +++ b/WebStack/Zope.py Mon Sep 06 21:31:04 2004 +0000 @@ -8,7 +8,7 @@ import Generic from Helpers import Environment -from Helpers.Request import Cookie, get_body_field +from Helpers.Request import Cookie, get_body_field, filter_fields from Helpers.Response import ConvertingStream from ZPublisher.HTTPRequest import FileUpload import cgi @@ -151,23 +151,30 @@ def get_fields_from_path(self): """ - Extracts the form fields from the path specified in the transaction. The - underlying framework may refuse to supply fields from the path if - handling a POST transaction. + Extracts fields (or request parameters) from the path specified in the + transaction. The underlying framework may refuse to supply fields from + the path if handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). """ - return cgi.parse_qs(self.get_query_string()) + # NOTE: Support at best ISO-8859-1 values. + + fields = {} + for name, values in cgi.parse_qs(self.get_query_string()).items(): + fields[name] = [] + for value in values: + fields[name].append(unicode(value, "iso-8859-1")) + return fields def get_fields_from_body(self, encoding=None): """ - Extracts the form fields from the message body in the transaction. The - optional 'encoding' parameter specifies the character encoding of the - message body for cases where no such information is available, but where - the default encoding is to be overridden. + Extracts fields (or request parameters) from the message body in the + transaction. The optional 'encoding' parameter specifies the character + encoding of the message body for cases where no such information is + available, but where the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). Each value is @@ -175,41 +182,57 @@ or a plain string (representing a file upload form field, for example). """ - # Fix the inclusion of path fields since this prevents Unicode conversion. + all_fields = self._get_fields(encoding) + fields_from_path = self.get_fields_from_path() + return filter_fields(all_fields, fields_from_path) - fields_from_path = self.get_fields_from_path() - + def _get_fields(self, encoding=None): encoding = encoding or self.get_content_type().charset or self.default_charset fields = {} for field_name, field_values in self.request.form.items(): - # Find the path values for this field (for filtering below). - - if fields_from_path.has_key(field_name): - field_from_path_values = fields_from_path[field_name] - if type(field_from_path_values) != type([]): - field_from_path_values = [field_from_path_values] - else: - field_from_path_values = [] - # Find the body values. if type(field_values) == type([]): fields[field_name] = [] for field_str in field_values: - # Filter path values. - if field_str not in field_from_path_values: - fields[field_name].append(get_body_field(field_str, encoding)) + fields[field_name].append(get_body_field(field_str, encoding)) + else: + fields[field_name] = [get_body_field(field_values, encoding)] + + return fields - # Remove filtered fields. + def get_fields(self, encoding=None): + + """ + Extracts fields (or request parameters) from both the path specified in + the transaction as well as the message body. The optional 'encoding' + parameter specifies the character encoding of the message body for cases + where no such information is available, but where the default encoding + is to be overridden. - if fields[field_name] == []: - del fields[field_name] - else: - # Filter path values. - if field_values not in field_from_path_values: - fields[field_name] = [get_body_field(field_values, encoding)] + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). Each value is + either a Unicode object (representing a simple form field, for example) + or a plain string (representing a file upload form field, for example). + + Where a given field name is used in both the path and message body to + specify values, the values from both sources will be combined into a + single list associated with that field name. + """ + # NOTE: Zope seems to provide only body fields upon POST requests. + + if self.get_request_method() == "GET": + return self._get_fields(encoding) + else: + fields = {} + fields.update(self.get_fields_from_path()) + for name, values in self._get_fields(encoding).items(): + if not fields.has_key(name): + fields[name] = values + else: + fields[name] += values return fields def get_user(self):