source: products/qClickTrackingTool/tags/0.4.2/skins/qClickTrackingTool/track.py

Last change on this file was 1, checked in by myroslav, 19 years ago

Building directory structure

File size: 888 bytes
Line 
1from Products.CMFCore.utils import getToolByName
2request=container.REQUEST
3RESPONSE= request.RESPONSE
4
5path='/'.join(traverse_subpath)
6default='/'
7map=container.getTrackMap()
8
9if path in map.keys():
10    target=map[path]
11else:
12    target=default
13
14# If the link is absolute, it should be just forwarded
15if 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
21root=getToolByName(context, 'portal_url').getPortalObject().absolute_url()
22if target.startswith('/'):
23    return RESPONSE.redirect(root+target)
24
25# Another option is to try to find the object in the ZODB
26target=container.restrictedTraverse(target, None)
27if target:
28    return RESPONSE.redirect(target.absolute_url())
29
30# Or fallback to root of portal
31return RESPONSE.redirect(root)
Note: See TracBrowser for help on using the repository browser.