# HG changeset patch # User paulb # Date 1085949137 0 # Node ID 5f6cf607d342fd54214ace5f55de68d3375257fd # Parent 3eb84d3448ffff467ec338d23f40393e2ac6574d [project @ 2004-05-30 20:32:17 by paulb] Added get_path_without_query. diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sun May 30 20:32:17 2004 +0000 @@ -140,6 +140,17 @@ return self.trans.path + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + + # Remove the query string from the end of the path. + + return self.trans.path.split("?")[0] + def get_path_info(self): """ @@ -148,9 +159,7 @@ request. """ - # Remove the query string from the end of the path. - - return self.trans.path.split("?")[0] + return self.get_path_without_query() def get_query_string(self): diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/CGI.py --- a/WebStack/CGI.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/CGI.py Sun May 30 20:32:17 2004 +0000 @@ -143,13 +143,23 @@ A framework-specific method which gets the entire path from the request. """ + path = self.get_path_without_query() + qs = self.get_query_string() + if qs: + path += "?" + path += qs + return path + + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + path = self.env.get("SCRIPT_NAME") or "" if self.env.has_key("PATH_INFO"): path += self.env["PATH_INFO"] - qs = self.env.get("QUERY_STRING") - if qs: - path += "?" - path += qs return path def get_path_info(self): diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/Generic.py --- a/WebStack/Generic.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/Generic.py Sun May 30 20:32:17 2004 +0000 @@ -195,6 +195,15 @@ raise NotImplementedError, "get_path" + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + + raise NotImplementedError, "get_path_without_query" + def get_path_info(self): """ diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/JavaServlet.py --- a/WebStack/JavaServlet.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/JavaServlet.py Sun May 30 20:32:17 2004 +0000 @@ -167,6 +167,22 @@ A framework-specific method which gets the entire path from the request. """ + # NOTE: To be verified. + + path = self.get_path_without_query() + qs = self.get_query_string() + if qs: + path += "?" + path += qs + return path + + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + return self.request.getServletPath() def get_path_info(self): diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/ModPython.py --- a/WebStack/ModPython.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/ModPython.py Sun May 30 20:32:17 2004 +0000 @@ -109,6 +109,15 @@ else: return self.trans.uri + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + + return self.trans.uri + def get_path_info(self): """ diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/Twisted.py --- a/WebStack/Twisted.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/Twisted.py Sun May 30 20:32:17 2004 +0000 @@ -99,6 +99,15 @@ return self.trans.uri + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + + return self.get_path().split("?")[0] + def get_path_info(self): """ diff -r 3eb84d3448ff -r 5f6cf607d342 WebStack/Webware.py --- a/WebStack/Webware.py Sun May 30 20:02:49 2004 +0000 +++ b/WebStack/Webware.py Sun May 30 20:32:17 2004 +0000 @@ -122,6 +122,15 @@ return self.trans.request().uri() + def get_path_without_query(self): + + """ + A framework-specific method which gets the entire path from the request + minus the query string. + """ + + return self.get_path().split("?")[0] + def get_path_info(self): """