Commit 42eb8e58 authored by Christopher Petrilli's avatar Christopher Petrilli

Merged in changes for path management, adding method

physicalPathToVirtualPath to the REQUEST object.
parent acb3d074
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.41 $'[11:-2] __version__='$Revision: 1.42 $'[11:-2]
import regex, re, sys, os, string, urllib import regex, re, sys, os, string, urllib
from string import lower, atoi, rfind, split, strip, join, upper, find from string import lower, atoi, rfind, split, strip, join, upper, find
...@@ -221,6 +221,28 @@ class HTTPRequest(BaseRequest): ...@@ -221,6 +221,28 @@ class HTTPRequest(BaseRequest):
other['VirtualRootPhysicalPath'] = parents[-1].getPhysicalPath() other['VirtualRootPhysicalPath'] = parents[-1].getPhysicalPath()
self._resetURLS() self._resetURLS()
def physicalPathToVirtualPath(self, path):
""" Remove the path to the VirtualRoot from a physical path """
if type(path) is type(''):
path = split(path, '/')
rpp = self.other.get('VirtualRootPhysicalPath', ('',))
i = 0
for name in rpp[:len(path)]:
if path[i] == name:
i = i + 1
else:
break
return path[i:]
def physicalPathToURL(self, path, relative=0):
""" Convert a physical path into a URL in the current context """
path = self._script + map(quote, self.physicalPathToVirtualPath(path))
if relative:
path.insert(0, '')
else:
path.insert(0, self['SERVER_URL'])
return join(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