[Zope] Virtual Host Monster does not work with the absolute_url()
Dieter Maurer
dieter@handshake.de
Sat, 10 Aug 2002 16:13:06 +0200
Tom Cameron writes:
> Does anybody know of a property or method that I should be looking for that
> absolute_url() might need to determine the correct Base?
Following the code of the standard "absolute_url" (to be found
in "OFS/Traversable"):
def absolute_url(self, relative=0):
try:
req = self.REQUEST
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:])
if relative:
# This is useful for physical path relative to a VirtualRoot
return join(path, '/')
return join([req['SERVER_URL']] + req._script + path, '/')
As you see, there are several possible reasons why you may get
the physical path:
* your object is unable to acquire "REQUEST" (because it is not
(yet) acquisition wrapped)
* the 'VirtualRootPhysicalPath' in "REQUEST" is wrong (not very likely)
* the SERVER_URL or "_script" in "REQUEST" are wrong (not very likely)
* you happen to access a non-standard "absolute_url" (use, e.g. "DocFinder",
to check that).
Dieter