1.1 --- a/WebStack/BaseHTTPRequestHandler.py Wed Feb 25 22:29:56 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Wed Feb 25 22:30:23 2004 +0000
1.3 @@ -132,16 +132,66 @@
1.4
1.5 return self.trans.path
1.6
1.7 + def get_query_string(self):
1.8 +
1.9 + """
1.10 + A framework-specific method which gets the query string from the path in
1.11 + the request.
1.12 + """
1.13 +
1.14 + t = self.trans.path.split("?")
1.15 + if len(t) == 1:
1.16 + return ""
1.17 + else:
1.18 +
1.19 + # NOTE: Overlook erroneous usage of "?" characters in the path.
1.20 +
1.21 + return "?".join(t[1:])
1.22 +
1.23 # Higher level request-related methods.
1.24
1.25 + def get_fields_from_path(self):
1.26 +
1.27 + """
1.28 + A framework-specific method which extracts the form fields from the
1.29 + path specified in the transaction. The underlying framework may refuse
1.30 + to supply fields from the path if handling a POST transaction.
1.31 +
1.32 + The returned object should employ the cgi.FieldStorage interface.
1.33 + """
1.34 +
1.35 + # NOTE: Since the cgi.FieldStorage class employed in this implementation
1.36 + # NOTE: will only provide fields from the path for GET transactions, the
1.37 + # NOTE: environment is adjusted to persuade it to give the desired
1.38 + # NOTE: output.
1.39 +
1.40 + return FieldStorage(headers=self.get_headers(), environ={"REQUEST_METHOD" : "GET",
1.41 + "QUERY_STRING" : self.get_query_string()}, keep_blank_values=1)
1.42 +
1.43 + def get_fields_from_body(self):
1.44 +
1.45 + """
1.46 + A framework-specific method which extracts the form fields from the
1.47 + message body in the transaction.
1.48 +
1.49 + The returned object should employ the cgi.FieldStorage interface.
1.50 + """
1.51 +
1.52 + return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(),
1.53 + environ={"REQUEST_METHOD" : "POST"}, keep_blank_values=1)
1.54 +
1.55 def get_fields(self):
1.56
1.57 """
1.58 A framework-specific method which extracts the form fields from the
1.59 - transaction.
1.60 + transaction. Typically, the origin of the form fields will be affected
1.61 + by the method specified in the transaction.
1.62 +
1.63 + The returned object should employ the cgi.FieldStorage interface.
1.64 """
1.65
1.66 - return FieldStorage(self.get_request_stream(), keep_blank_values=1)
1.67 + return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(),
1.68 + environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1)
1.69
1.70 def get_user(self):
1.71
2.1 --- a/WebStack/Generic.py Wed Feb 25 22:29:56 2004 +0000
2.2 +++ b/WebStack/Generic.py Wed Feb 25 22:30:23 2004 +0000
2.3 @@ -201,11 +201,48 @@
2.4
2.5 raise NotImplementedError, "get_path_info"
2.6
2.7 + def get_query_string(self):
2.8 +
2.9 + """
2.10 + A framework-specific method which gets the query string from the path in
2.11 + the request.
2.12 + """
2.13 +
2.14 + raise NotImplementedError, "get_query_string"
2.15 +
2.16 + # Higher level request-related methods.
2.17 +
2.18 + def get_fields_from_path(self):
2.19 +
2.20 + """
2.21 + A framework-specific method which extracts the form fields from the
2.22 + path specified in the transaction. The underlying framework may refuse
2.23 + to supply fields from the path if handling a POST transaction.
2.24 +
2.25 + The returned object should employ the cgi.FieldStorage interface.
2.26 + """
2.27 +
2.28 + raise NotImplementedError, "get_fields_from_path"
2.29 +
2.30 + def get_fields_from_body(self):
2.31 +
2.32 + """
2.33 + A framework-specific method which extracts the form fields from the
2.34 + message body in the transaction.
2.35 +
2.36 + The returned object should employ the cgi.FieldStorage interface.
2.37 + """
2.38 +
2.39 + raise NotImplementedError, "get_fields_from_body"
2.40 +
2.41 def get_fields(self):
2.42
2.43 """
2.44 A framework-specific method which extracts the form fields from the
2.45 - transaction.
2.46 + transaction. Typically, the origin of the form fields will be affected
2.47 + by the method specified in the transaction.
2.48 +
2.49 + The returned object should employ the cgi.FieldStorage interface.
2.50 """
2.51
2.52 raise NotImplementedError, "get_fields"
3.1 --- a/WebStack/ModPython.py Wed Feb 25 22:29:56 2004 +0000
3.2 +++ b/WebStack/ModPython.py Wed Feb 25 22:30:23 2004 +0000
3.3 @@ -102,13 +102,56 @@
3.4
3.5 return self.trans.path_info
3.6
3.7 + def get_query_string(self):
3.8 +
3.9 + """
3.10 + A framework-specific method which gets the query string from the path in
3.11 + the request.
3.12 + """
3.13 +
3.14 + return self.trans.args
3.15 +
3.16 # Higher level request-related methods.
3.17
3.18 + def get_fields_from_path(self):
3.19 +
3.20 + """
3.21 + A framework-specific method which extracts the form fields from the
3.22 + path specified in the transaction. The underlying framework may refuse
3.23 + to supply fields from the path if handling a POST transaction.
3.24 +
3.25 + The returned object should employ the cgi.FieldStorage interface.
3.26 +
3.27 + The mod_python.util.FieldStorage class should get fields from the path
3.28 + in all situations, although it may then redefine such fields if
3.29 + identically-named fields are then specified in the body of a POST
3.30 + transaction.
3.31 + """
3.32 +
3.33 + return self.get_fields()
3.34 +
3.35 + def get_fields_from_body(self):
3.36 +
3.37 + """
3.38 + A framework-specific method which extracts the form fields from the
3.39 + message body in the transaction.
3.40 +
3.41 + The returned object should employ the cgi.FieldStorage interface.
3.42 +
3.43 + The mod_python.util.FieldStorage class may augment the fields from the
3.44 + body with fields found in the path.
3.45 + """
3.46 +
3.47 + return self.get_fields()
3.48 +
3.49 def get_fields(self):
3.50
3.51 """
3.52 A framework-specific method which extracts the form fields from the
3.53 - transaction.
3.54 + transaction. Typically, the origin of the form fields will be affected
3.55 + by the method specified in the transaction.
3.56 +
3.57 + The returned object should employ the cgi.FieldStorage interface.
3.58 """
3.59
3.60 return FieldStorage(self.trans, keep_blank_values=1)
4.1 --- a/WebStack/Twisted.py Wed Feb 25 22:29:56 2004 +0000
4.2 +++ b/WebStack/Twisted.py Wed Feb 25 22:30:23 2004 +0000
4.3 @@ -91,9 +91,7 @@
4.4 A framework-specific method which gets the entire path from the request.
4.5 """
4.6
4.7 - # NOTE: The path and "path info" are mostly equivalent for Twisted.
4.8 -
4.9 - return self.get_path_info()
4.10 + return self.trans.uri
4.11
4.12 def get_path_info(self):
4.13
4.14 @@ -105,18 +103,64 @@
4.15
4.16 return "/%s" % "/".join(self.trans.postpath)
4.17
4.18 + def get_query_string(self):
4.19 +
4.20 + """
4.21 + A framework-specific method which gets the query string from the path in
4.22 + the request.
4.23 + """
4.24 +
4.25 + t = self.get_path().split("?")
4.26 + if len(t) == 1:
4.27 + return ""
4.28 + else:
4.29 +
4.30 + # NOTE: Overlook erroneous usage of "?" characters in the path.
4.31 +
4.32 + return "?".join(t[1:])
4.33 +
4.34 # Higher level request-related methods.
4.35
4.36 + def get_fields_from_path(self):
4.37 +
4.38 + """
4.39 + A framework-specific method which extracts the form fields from the
4.40 + path specified in the transaction. The underlying framework may refuse
4.41 + to supply fields from the path if handling a POST transaction.
4.42 +
4.43 + The returned object should employ the cgi.FieldStorage interface.
4.44 + """
4.45 +
4.46 + # NOTE: May need a wrapper around this object.
4.47 +
4.48 + return self.trans.args
4.49 +
4.50 + def get_fields_from_body(self):
4.51 +
4.52 + """
4.53 + A framework-specific method which extracts the form fields from the
4.54 + message body in the transaction.
4.55 +
4.56 + The returned object should employ the cgi.FieldStorage interface.
4.57 + """
4.58 +
4.59 + # NOTE: May need a wrapper around this object.
4.60 +
4.61 + return self.trans.args
4.62 +
4.63 def get_fields(self):
4.64
4.65 """
4.66 A framework-specific method which extracts the form fields from the
4.67 - transaction.
4.68 + transaction. Typically, the origin of the form fields will be affected
4.69 + by the method specified in the transaction.
4.70 +
4.71 + The returned object should employ the cgi.FieldStorage interface.
4.72 """
4.73
4.74 - # NOTE: Discard multiple field values.
4.75 + # NOTE: May need a wrapper around this object.
4.76
4.77 - return dict([(key, value[0]) for (key, value) in self.trans.args.items()])
4.78 + return self.trans.args
4.79
4.80 def get_user(self):
4.81
5.1 --- a/WebStack/Webware.py Wed Feb 25 22:29:56 2004 +0000
5.2 +++ b/WebStack/Webware.py Wed Feb 25 22:30:23 2004 +0000
5.3 @@ -112,13 +112,54 @@
5.4
5.5 return "/" + self.trans.request().pathInfo()
5.6
5.7 + def get_query_string(self):
5.8 +
5.9 + """
5.10 + A framework-specific method which gets the query string from the path in
5.11 + the request.
5.12 + """
5.13 +
5.14 + return self.trans.request().queryString()
5.15 +
5.16 # Higher level request-related methods.
5.17
5.18 + def get_fields_from_path(self):
5.19 +
5.20 + """
5.21 + A framework-specific method which extracts the form fields from the
5.22 + path specified in the transaction. The underlying framework may refuse
5.23 + to supply fields from the path if handling a POST transaction.
5.24 +
5.25 + The returned object should employ the cgi.FieldStorage interface.
5.26 +
5.27 + The result of this method is dependent on the WebUtils.FieldStorage
5.28 + module's FieldStorage class.
5.29 + """
5.30 +
5.31 + return self.trans.request().fields()
5.32 +
5.33 + def get_fields_from_body(self):
5.34 +
5.35 + """
5.36 + A framework-specific method which extracts the form fields from the
5.37 + message body in the transaction.
5.38 +
5.39 + The returned object should employ the cgi.FieldStorage interface.
5.40 +
5.41 + The result of this method is dependent on the WebUtils.FieldStorage
5.42 + module's FieldStorage class.
5.43 + """
5.44 +
5.45 + return self.trans.request().fields()
5.46 +
5.47 def get_fields(self):
5.48
5.49 """
5.50 A framework-specific method which extracts the form fields from the
5.51 - transaction.
5.52 + transaction. Typically, the origin of the form fields will be affected
5.53 + by the method specified in the transaction.
5.54 +
5.55 + The returned object should employ the cgi.FieldStorage interface.
5.56 """
5.57
5.58 return self.trans.request().fields()