[Zope-Checkins] CVS: Zope2 - HTTPRequest.py:1.48

Brian Lloyd brian@digicool.com
Tue, 27 Mar 2001 14:52:42 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/ZPublisher
In directory korak:/home/brian/temp/mainline_test/lib/python/ZPublisher

Modified Files:
	HTTPRequest.py 
Log Message:
Merged api cleanup of physicalPathFromURL



--- Updated File HTTPRequest.py in package Zope2 --
--- HTTPRequest.py	2001/03/12 21:26:20	1.47
+++ HTTPRequest.py	2001/03/27 19:52:41	1.48
@@ -246,6 +246,30 @@
             path.insert(0, self['SERVER_URL'])
         return join(path, '/')
 
+    def physicalPathFromURL(self, URL):
+        """ Convert a URL into a physical path in the current context.
+            If the URL makes no sense in light of the current virtual
+            hosting context, a ValueError is raised."""
+        other = self.other
+        bad_server_url = 0
+        path = filter(None, split(URL, '/'))
+
+        if find(URL, '://') >= 0:
+            path = path[2:]
+
+        # Check the path against BASEPATH1
+        vhbase = self._script
+        vhbl = len(vhbase)
+        bad_basepath = 0
+        if path[:vhbl] == vhbase:
+            path = path[vhbl:]
+        else:
+            raise ValueError, (
+                'Url does not match virtual hosting context'
+                )
+        vrpp = other.get('VirtualRootPhysicalPath', ('',))
+        return list(vrpp) + map(unquote, path)
+
     def _resetURLS(self):
         other = self.other
         other['URL'] = join([other['SERVER_URL']] + self._script +