Commit e15ecb45 authored by 's avatar

Merged api cleanup of physicalPathFromURL

parent 19a3977d
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.47 $'[11:-2] __version__='$Revision: 1.48 $'[11:-2]
import regex, re, sys, os, string, urllib, time, whrandom import regex, re, sys, os, string, urllib, time, whrandom
from string import lower, atoi, rfind, split, strip, join, upper, find from string import lower, atoi, rfind, split, strip, join, upper, find
...@@ -246,6 +246,30 @@ class HTTPRequest(BaseRequest): ...@@ -246,6 +246,30 @@ class HTTPRequest(BaseRequest):
path.insert(0, self['SERVER_URL']) path.insert(0, self['SERVER_URL'])
return join(path, '/') 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): def _resetURLS(self):
other = self.other other = self.other
other['URL'] = join([other['SERVER_URL']] + self._script + other['URL'] = join([other['SERVER_URL']] + self._script +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment