[Zope3-checkins] CVS: Zope3/src/zope/app/browser - absoluteurl.py:1.5
Marius Gedminas
mgedmin@codeworks.lt
Mon, 28 Apr 2003 09:14:50 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv25303/src/zope/app/browser
Modified Files:
absoluteurl.py
Log Message:
Virtual hosting did not work correctly in all cases (e.g. service configuration
paths did not have leading path elements truncated when they should have).
This is now fixed by adding a method getVirtualHostRoot to IVirtualHostRequest
and making AbsoluteURL views use that for identifying the virtual host root
instead of relying on special context wrappers. Also added a functional test
to prevent regressions.
=== Zope3/src/zope/app/browser/absoluteurl.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/absoluteurl.py:1.4 Tue Apr 15 06:57:08 2003
+++ Zope3/src/zope/app/browser/absoluteurl.py Mon Apr 28 09:14:19 2003
@@ -18,24 +18,32 @@
"""
from zope.publisher.browser import BrowserView
from zope.proxy.context import getWrapperContainer, getInnerWrapperData
+from zope.proxy.introspection import removeAllProxies
from zope.component import getView
class AbsoluteURLBase(BrowserView):
def __str__(self):
context = self.context
+ vh_root = removeAllProxies(self.request.getVirtualHostRoot())
+ if removeAllProxies(context) is vh_root:
+ return self.request.getApplicationURL()
+ container = getWrapperContainer(context)
+ container_url = str(getView(container, 'absolute_url',
+ self.request))
dict = getInnerWrapperData(context)
name = dict and dict.get('name') or None
if name == '.':
name = dict.get('side_effect_name', name)
if name.startswith('++vh++'):
- return self.request.getApplicationURL()
- container = getWrapperContainer(context)
- return "%s/%s" % (getView(container, 'absolute_url', self.request),
- name)
+ return container_url
+ return "%s/%s" % (container_url, name)
def breadcrumbs(self):
context = self.context
+ vh_root = removeAllProxies(self.request.getVirtualHostRoot())
+ if removeAllProxies(context) is vh_root:
+ return ({'name':'', 'url': self.request.getApplicationURL()}, )
dict = getInnerWrapperData(context)
name = dict and dict.get('name') or None
container = getWrapperContainer(context)
@@ -46,7 +54,7 @@
# that we need to preserve in the urls (only)
name = dict.get('side_effect_name', name)
if name.startswith('++vh++'):
- return ({'name':'', 'url': self.request.getApplicationURL()}, )
+ return base
# replace the last step in base with a step with the same
# name and an augmented url