[Zope] How to get exact requested URL (was: Current location: is my
script reliable?)
Tonico Strasser
contact_tonico at yahoo.de
Fri Jun 25 09:21:22 EDT 2004
If you need the exact URL that was requested by the browser including
*) trailing and double slashes and
*) query strings,
then the attached script is for you.
Example usage:
tal:define="location here/location"
tal:attributes="href string:$location#documentContent"
I've tested it with several Zope versions and vhost setups.
Related issues:
Skipnav loads new page
<http://plone.org/collector/2775>
base tag differs from actual url
<http://plone.org/collector/2988>
VIRTUAL_URL
<http://collector.zope.org/Zope/1252>
Need "actual URL" method
<http://collector.zope.org/Zope/1308>
HTH
Tonico
-------------- next part --------------
## Script (Python) "location"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = context.REQUEST
server_url = request['SERVER_URL']
path_info = request['PATH_INFO']
query_string = request['QUERY_STRING']
path_info = path_info.split('VirtualHostRoot')[-1]
# This is needed with Zope.cgi (don't know why).
if path_info.startswith('//'):
path_info = path_info[1:]
if query_string:
query_string = '?%s' % query_string
location = server_url + path_info + query_string
return location
More information about the Zope
mailing list