Last change
on this file since 2523 was
494,
checked in by crchemist, 18 years ago
|
Added templates for appropriate mails
|
File size:
900 bytes
|
Rev | Line | |
---|
[494] | 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.