Commit 48728f92 authored by Evan Simpson's avatar Evan Simpson

Fix for #797 and #809 -- delegate absolute_url internals to REQUEST and

provide a docstring.
parent 8f3979d9
......@@ -71,6 +71,11 @@ Zope Changes
Bugs Fixed
- Collector: #797 and #809: Application and Traversable now
delegate computation of absolute_url to the REQUEST object, and
both provide the same docstring. This makes absolute_url
callable by URL, and fixes virtual hosting inconsistencies.
- Collector: #964: standard_error_message refers to looking into the
HTML code for more information which is deprecated. Referring to
the error log now.
......
......@@ -12,8 +12,8 @@
##############################################################################
__doc__='''Application support
$Id: Application.py,v 1.191 2003/06/24 13:30:29 chrism Exp $'''
__version__='$Revision: 1.191 $'[11:-2]
$Id: Application.py,v 1.192 2003/07/08 17:03:52 evan Exp $'''
__version__='$Revision: 1.192 $'[11:-2]
import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
import time, traceback, os, Products
......@@ -135,11 +135,21 @@ class Application(Globals.ApplicationDefaultPermissions,
test_url=ZopeAttributionButton
def absolute_url(self, relative=0):
"""Return an absolute url to the object. Note that the url
will reflect the acquisition path of the object if the object
has been acquired."""
if relative: return ''
return self.aq_acquire('REQUEST')['BASE1']
'''Return a canonical URL for this object based on its
physical containment path, possibly modified by virtual hosting.
If the optional 'relative' argument is true, only return the
path portion of the URL.'''
try:
# We need a REQUEST that uses physicalPathToURL to create
# BASE1 and BASEPATH1, so probe for it.
req = self.REQUEST
req.physicalPathToURL
except AttributeError:
return ''
# Take advantage of computed URL cache
if relative:
return req['BASEPATH1'][1:]
return req['BASE1']
def getPhysicalPath(self):
'''Returns a path that can be used to access this object again
......
......@@ -12,8 +12,8 @@
##############################################################################
'''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.19 2003/04/17 17:46:57 fdrake Exp $'''
__version__='$Revision: 1.19 $'[11:-2]
$Id: Traversable.py,v 1.20 2003/07/08 17:03:52 evan Exp $'''
__version__='$Revision: 1.20 $'[11:-2]
from Acquisition import Acquired, aq_inner, aq_parent, aq_base
......@@ -30,23 +30,19 @@ class Traversable:
absolute_url__roles__=None # Public
def absolute_url(self, relative=0):
'''Return a canonical URL for this object based on its
physical containment path, possibly modified by virtual hosting.
If the optional 'relative' argument is true, only return the
path portion of the URL.'''
spp = self.getPhysicalPath()
try:
req = self.REQUEST
toUrl = self.REQUEST.physicalPathToURL
except AttributeError:
req = {}
rpp = req.get('VirtualRootPhysicalPath', ('',))
spp = self.getPhysicalPath()
i = 0
for name in rpp[:len(spp)]:
if spp[i] == name:
i = i + 1
else:
break
path = map(quote, spp[i:])
return '/'.join(map(quote, spp[1:]))
if relative:
# This is useful for physical path relative to a VirtualRoot
return '/'.join(path)
return '/'.join([req['SERVER_URL']] + req._script + path)
# Remove leading slash for backward compatibility sake.
return toUrl(spp, relative)[1:]
return toUrl(spp)
getPhysicalRoot__roles__=() # Private
getPhysicalRoot=Acquired
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment