[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/traversing/browser/ Fixed issue 418: '/++etc++process' doesn't work for virtual hosts

Dmitry Vasiliev dima at hlabs.spb.ru
Wed Jun 22 09:48:36 EDT 2005


Log message for revision 30886:
  Fixed issue 418: '/++etc++process' doesn't work for virtual hosts
  

Changed:
  U   Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
  U   Zope3/trunk/src/zope/app/traversing/browser/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py	2005-06-22 12:47:33 UTC (rev 30885)
+++ Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py	2005-06-22 13:48:35 UTC (rev 30886)
@@ -47,7 +47,8 @@
         # The application URL contains all the namespaces that are at the
         # beginning of the URL, such as skins, virtual host specifications and
         # so on.
-        if sameProxiedObjects(context, request.getVirtualHostRoot()):
+        if (context is None
+            or sameProxiedObjects(context, request.getVirtualHostRoot())):
             return request.getApplicationURL()
 
         container = getattr(context, '__parent__', None)

Modified: Zope3/trunk/src/zope/app/traversing/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/tests.py	2005-06-22 12:47:33 UTC (rev 30885)
+++ Zope3/trunk/src/zope/app/traversing/browser/tests.py	2005-06-22 13:48:35 UTC (rev 30886)
@@ -54,7 +54,7 @@
         request = TestRequest()
         content = contained(TrivialContent(), Root(), name='a')
         view = zapi.getMultiAdapter((content, request), name='absolute_url')
-        
+
         verifyObject(IAbsoluteURL, view)
 
     def testBadObject(self):
@@ -139,7 +139,6 @@
                           {'name': 'b', 'url': base + '/a/b'},
                           {'name': 'c', 'url': base + '/a/b/c'},
                           ))
-        
 
     def testVirtualHosting(self):
         request = TestRequest()
@@ -197,7 +196,20 @@
           {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
           ))
 
+    def testNoContextInformation(self):
+        request = TestRequest()
+        view = zapi.getMultiAdapter((None, request), name='absolute_url')
+        self.assertEqual(str(view), 'http://127.0.0.1')
+        self.assertEqual(absoluteURL(None, request), 'http://127.0.0.1')
 
+    def testVirtualHostingWithoutContextInformation(self):
+        request = TestRequest()
+        request._vh_root = contained(TrivialContent(), Root(), name='a')
+        view = zapi.getMultiAdapter((None, request), name='absolute_url')
+        self.assertEqual(str(view), 'http://127.0.0.1')
+        self.assertEqual(absoluteURL(None, request), 'http://127.0.0.1')
+
+
 def test_suite():
     return makeSuite(TestAbsoluteURL)
 



More information about the Zope3-Checkins mailing list