# HG changeset patch # User paulb # Date 1108825353 0 # Node ID aab83a5e22fd425123a81a78d43409e45a14c8ef # Parent baf01fefa898131dac07ca9d52cd24c793311b8d [project @ 2005-02-19 15:02:33 by paulb] Removed the influence of path info modifications on get_path_info, introducing special methods for the setting and retrieval of modified path info. diff -r baf01fefa898 -r aab83a5e22fd WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sat Feb 19 15:02:33 2005 +0000 @@ -179,10 +179,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return self.get_path_without_query() + return self.get_path_without_query() def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/CGI.py --- a/WebStack/CGI.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/CGI.py Sat Feb 19 15:02:33 2005 +0000 @@ -178,10 +178,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return self.env.get("PATH_INFO") or "" + return self.env.get("PATH_INFO") or "" def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/Generic.py --- a/WebStack/Generic.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/Generic.py Sat Feb 19 15:02:33 2005 +0000 @@ -531,15 +531,25 @@ self.user = username - def set_path_info(self, path_info): + def set_virtual_path_info(self, path_info): """ An application-specific method which sets the 'path_info' in the - transaction. This affects subsequent calls to 'get_path_info'. + transaction. This affects subsequent calls to 'get_virtual_path_info'. """ self.path_info = path_info + def get_virtual_path_info(self): + + """ + An application-specific method which either returns path info set in the + 'set_virtual_path_info' method, or the normal path info found in the + request. + """ + + return self.path_info or self.get_path_info() + class Resource: "A generic resource interface." diff -r baf01fefa898 -r aab83a5e22fd WebStack/JavaServlet.py --- a/WebStack/JavaServlet.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/JavaServlet.py Sat Feb 19 15:02:33 2005 +0000 @@ -211,10 +211,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return self.request.getPathInfo() or "" + return self.request.getPathInfo() or "" def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/ModPython.py --- a/WebStack/ModPython.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/ModPython.py Sat Feb 19 15:02:33 2005 +0000 @@ -162,10 +162,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return self.trans.path_info + return self.trans.path_info def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/Twisted.py --- a/WebStack/Twisted.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/Twisted.py Sat Feb 19 15:02:33 2005 +0000 @@ -133,10 +133,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return "/%s" % "/".join(self.trans.postpath) + return "/%s" % "/".join(self.trans.postpath) def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/WSGI.py --- a/WebStack/WSGI.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/WSGI.py Sat Feb 19 15:02:33 2005 +0000 @@ -181,10 +181,7 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - return self.env.get("PATH_INFO") or "" + return self.env.get("PATH_INFO") or "" def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/Webware.py --- a/WebStack/Webware.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/Webware.py Sat Feb 19 15:02:33 2005 +0000 @@ -139,15 +139,12 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info + path_info = self.trans.request().pathInfo() + context_name = self.trans.request().contextName() + if path_info.startswith(context_name): + return path_info[len(context_name):] else: - path_info = self.trans.request().pathInfo() - context_name = self.trans.request().contextName() - if path_info.startswith(context_name): - return path_info[len(context_name):] - else: - return path_info + return path_info def get_query_string(self): diff -r baf01fefa898 -r aab83a5e22fd WebStack/Zope.py --- a/WebStack/Zope.py Sat Feb 19 14:23:47 2005 +0000 +++ b/WebStack/Zope.py Sat Feb 19 15:02:33 2005 +0000 @@ -143,12 +143,9 @@ handling the current request) from the request. """ - if self.path_info is not None: - return self.path_info - else: - product_path = "/".join(self.adapter.getPhysicalPath()) - path_info = self.request.environ.get("PATH_INFO") or "" - return path_info[len(product_path):] + product_path = "/".join(self.adapter.getPhysicalPath()) + path_info = self.request.environ.get("PATH_INFO") or "" + return path_info[len(product_path):] def get_query_string(self):