[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - resource.py:1.3

Albertas Agejevas alga@codeworks.lt
Tue, 15 Apr 2003 08:25:03 -0400


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv11793/src/zope/app/publisher/browser

Modified Files:
	resource.py 
Log Message:
Added virtual hosting support to resources, complete with unit tests
and functional tests.



=== Zope3/src/zope/app/publisher/browser/resource.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/publisher/browser/resource.py:1.2	Wed Dec 25 09:13:09 2002
+++ Zope3/src/zope/app/publisher/browser/resource.py	Tue Apr 15 08:24:33 2003
@@ -20,6 +20,7 @@
 from zope.component import queryView
 from zope.proxy.context import getWrapperContainer, getInnerWrapperData
 from zope.proxy.context import ContextMethod
+from zope.app.traversing import joinPath
 
 class Resource:
 
@@ -36,20 +37,21 @@
 
         skin = wrapped_self.request.getPresentationSkin()
         if skin:
-            skin = "++skin++%s/" % skin
+            skin = "++skin++%s" % skin
 
-        if site is None:
-            return "/%s@@/%s" % (skin, name)
+        base_url = wrapped_self.request.getApplicationURL(path_only=True)
 
-        absolute_url = queryView(service,
-                                 'absolute_url',
-                                 wrapped_self.request)
+        if site is not None:
+            raise NotImplementedError("This code path is not tested")
+            absolute_url = queryView(service,
+                                     'absolute_url',
+                                     wrapped_self.request)
+            if absolute_url is not None:
+                base_url = absolute_url()
 
-        if absolute_url is None:
-            return "/%s@@/%s" % (skin, name)
-
-        site_url = absolute_url()
-
-        return "%s/%s@@/%s" % (site_url, skin, name)
+        if skin:
+            return joinPath(base_url, skin, '@@', name) # XXX joinPath should
+        else:                                           # XXX eat empty path
+            return joinPath(base_url, '@@', name)       # XXX elements
 
     __call__ = ContextMethod(__call__)