Last change
on this file since 1653 was
491,
checked in by piv, 18 years ago
|
ie compatibility
|
-
Property svn:eol-style set to
native
|
File size:
900 bytes
|
Line | |
---|
1 | # |
---|
2 | from ZPublisher.HTTPRequest import HTTPRequest |
---|
3 | from ZPublisher.BaseRequest import quote |
---|
4 | |
---|
5 | def physicalPathToURL(self, path, relative=0): |
---|
6 | """ Convert a physical path into a URL in the current context """ |
---|
7 | url = self['SERVER_URL'] |
---|
8 | proto = url.split('://')[0] |
---|
9 | |
---|
10 | if not type(path) == type(''): |
---|
11 | path = '/'.join(path) |
---|
12 | |
---|
13 | path_domain_map = getattr(self, 'path_domain_map', ()) |
---|
14 | for subpath, domain in path_domain_map: |
---|
15 | if len(path) >= len(subpath) \ |
---|
16 | and (path == subpath \ |
---|
17 | or path.startswith(subpath+'/')): |
---|
18 | url = "%s://%s" % (proto, domain) |
---|
19 | path = path[len(subpath):] |
---|
20 | break |
---|
21 | |
---|
22 | path = self._script + map(quote, self.physicalPathToVirtualPath(path)) |
---|
23 | if relative: |
---|
24 | path.insert(0, '') |
---|
25 | else: |
---|
26 | path.insert(0, url) |
---|
27 | return '/'.join(path) |
---|
28 | |
---|
29 | HTTPRequest.physicalPathToURL = physicalPathToURL |
---|
Note: See
TracBrowser
for help on using the repository browser.