# HG changeset patch # User paulb # Date 1078001718 0 # Node ID 231a1d235cb166a9c75803acd63074fab28cb6ec # Parent 6af2265e90b887184eaad20a5a4cb584b5dbd6ff [project @ 2004-02-28 20:55:18 by paulb] Removed get_fields, since it would be ambiguous. Fixed get_fields_from_body (for most frameworks) and get_query_string (for mod_python). diff -r 6af2265e90b8 -r 231a1d235cb1 WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sat Feb 28 16:30:00 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sat Feb 28 20:55:18 2004 +0000 @@ -169,24 +169,19 @@ A framework-specific method which extracts the form fields from the message body in the transaction. - The returned object should employ the cgi.FieldStorage interface. + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). """ - return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(), - environ={"REQUEST_METHOD" : "POST"}, keep_blank_values=1) + storage = FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(), + environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1) - def get_fields(self): + # Traverse the storage, finding each field value. - """ - A framework-specific method which extracts the form fields from the - transaction. Typically, the origin of the form fields will be affected - by the method specified in the transaction. - - The returned object should employ the cgi.FieldStorage interface. - """ - - return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(), - environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1) + fields = {} + for field_name in storage.keys(): + fields[field_name] = storage.getlist(field_name) + return fields def get_user(self): diff -r 6af2265e90b8 -r 231a1d235cb1 WebStack/Generic.py --- a/WebStack/Generic.py Sat Feb 28 16:30:00 2004 +0000 +++ b/WebStack/Generic.py Sat Feb 28 20:55:18 2004 +0000 @@ -231,23 +231,12 @@ A framework-specific method which extracts the form fields from the message body in the transaction. - The returned object should employ the cgi.FieldStorage interface. + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). """ raise NotImplementedError, "get_fields_from_body" - def get_fields(self): - - """ - A framework-specific method which extracts the form fields from the - transaction. Typically, the origin of the form fields will be affected - by the method specified in the transaction. - - The returned object should employ the cgi.FieldStorage interface. - """ - - raise NotImplementedError, "get_fields" - def get_user(self): """ diff -r 6af2265e90b8 -r 231a1d235cb1 WebStack/ModPython.py --- a/WebStack/ModPython.py Sat Feb 28 16:30:00 2004 +0000 +++ b/WebStack/ModPython.py Sat Feb 28 20:55:18 2004 +0000 @@ -109,7 +109,7 @@ the request. """ - return self.trans.args + return self.trans.args or "" # Higher level request-related methods. @@ -132,25 +132,23 @@ A framework-specific method which extracts the form fields from the message body in the transaction. - The returned object should employ the cgi.FieldStorage interface. + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). The mod_python.util.FieldStorage class may augment the fields from the body with fields found in the path. """ - return self.get_fields() + storage = FieldStorage(self.trans, keep_blank_values=1) - def get_fields(self): + # Traverse the storage, finding each field value. - """ - A framework-specific method which extracts the form fields from the - transaction. Typically, the origin of the form fields will be affected - by the method specified in the transaction. - - The returned object should employ the cgi.FieldStorage interface. - """ - - return FieldStorage(self.trans, keep_blank_values=1) + fields = {} + for field in storage.list: + if not fields.has_key(field.name): + fields[field.name] = [] + fields[field.name].append(field.value) + return fields def get_user(self): diff -r 6af2265e90b8 -r 231a1d235cb1 WebStack/Twisted.py --- a/WebStack/Twisted.py Sat Feb 28 16:30:00 2004 +0000 +++ b/WebStack/Twisted.py Sat Feb 28 20:55:18 2004 +0000 @@ -141,25 +141,10 @@ A framework-specific method which extracts the form fields from the message body in the transaction. - The returned object should employ the cgi.FieldStorage interface. + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). """ - # NOTE: May need a wrapper around this object. - - return self.trans.args - - def get_fields(self): - - """ - A framework-specific method which extracts the form fields from the - transaction. Typically, the origin of the form fields will be affected - by the method specified in the transaction. - - The returned object should employ the cgi.FieldStorage interface. - """ - - # NOTE: May need a wrapper around this object. - return self.trans.args def get_user(self): diff -r 6af2265e90b8 -r 231a1d235cb1 WebStack/Webware.py --- a/WebStack/Webware.py Sat Feb 28 16:30:00 2004 +0000 +++ b/WebStack/Webware.py Sat Feb 28 20:55:18 2004 +0000 @@ -143,25 +143,19 @@ A framework-specific method which extracts the form fields from the message body in the transaction. - The returned object should employ the cgi.FieldStorage interface. - - The result of this method is dependent on the WebUtils.FieldStorage - module's FieldStorage class. + Returns a dictionary mapping field names to lists of values (even if a + single value is associated with any given field name). """ - return self.trans.request().fields() - - def get_fields(self): + # Fix the non-list results. - """ - A framework-specific method which extracts the form fields from the - transaction. Typically, the origin of the form fields will be affected - by the method specified in the transaction. - - The returned object should employ the cgi.FieldStorage interface. - """ - - return self.trans.request().fields() + fields = {} + for field_name, field_value in self.trans.request().fields().items(): + if type(field_value) == type([]): + fields[field_name] = field_value + else: + fields[field_name] = [field_value] + return fields def get_user(self):