Last change
on this file was
1,
checked in by myroslav, 19 years ago
|
Building directory structure
|
File size:
888 bytes
|
Line | |
---|
1 | from Products.CMFCore.utils import getToolByName |
---|
2 | request=container.REQUEST |
---|
3 | RESPONSE= request.RESPONSE |
---|
4 | |
---|
5 | path='/'.join(traverse_subpath) |
---|
6 | default='/' |
---|
7 | map=container.getTrackMap() |
---|
8 | |
---|
9 | if path in map.keys(): |
---|
10 | target=map[path] |
---|
11 | else: |
---|
12 | target=default |
---|
13 | |
---|
14 | # If the link is absolute, it should be just forwarded |
---|
15 | if target.startswith('http://') or \ |
---|
16 | target.startswith('https://') or \ |
---|
17 | target.startswith('ftp://') : |
---|
18 | return RESPONSE.redirect(target) |
---|
19 | |
---|
20 | # If it starts from root, it just starts from root of portal |
---|
21 | root=getToolByName(context, 'portal_url').getPortalObject().absolute_url() |
---|
22 | if target.startswith('/'): |
---|
23 | return RESPONSE.redirect(root+target) |
---|
24 | |
---|
25 | # Another option is to try to find the object in the ZODB |
---|
26 | target=container.restrictedTraverse(target, None) |
---|
27 | if target: |
---|
28 | return RESPONSE.redirect(target.absolute_url()) |
---|
29 | |
---|
30 | # Or fallback to root of portal |
---|
31 | return RESPONSE.redirect(root) |
---|
Note: See
TracBrowser
for help on using the repository browser.