[Zope3-checkins] CVS: Zope3/src/zope/publisher - base.py:1.6 http.py:1.24
Marius Gedminas
mgedmin@codeworks.lt
Mon, 28 Apr 2003 09:14:52 -0400
Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv25303/src/zope/publisher
Modified Files:
base.py http.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/publisher/base.py 1.5 => 1.6 ===
--- Zope3/src/zope/publisher/base.py:1.5 Fri Apr 25 06:36:38 2003
+++ Zope3/src/zope/publisher/base.py Mon Apr 28 09:14:21 2003
@@ -165,6 +165,7 @@
__slots__ = (
'_held', # Objects held until the request is closed
'_traversed_names', # The names that have been traversed
+ '_last_obj_traversed', # Object that was traversed last
'_traversal_stack', # Names to be traversed, in reverse order
'_environ', # The request environment variables
'_response', # The response
@@ -181,6 +182,7 @@
def __init__(self, body_instream, outstream, environ, response=None,
positional=()):
self._traversal_stack = []
+ self._last_obj_traversed = None
self._traversed_names = []
self._environ = environ
@@ -224,8 +226,11 @@
traversal_stack = self._traversal_stack
traversed_names = self._traversed_names
+ self._last_obj_traversed = object
+
prev_object = None
while 1:
+
if object is not prev_object:
# Invoke hooks (but not more than once).
publication.callTraversalHooks(self, object)
@@ -238,7 +243,7 @@
subobject = publication.traverseName(
self, object, entry_name)
traversed_names.append(entry_name)
- object = subobject
+ self._last_obj_traversed = object = subobject
else:
# Finished traversal.
break
=== Zope3/src/zope/publisher/http.py 1.23 => 1.24 ===
--- Zope3/src/zope/publisher/http.py:1.23 Fri Apr 25 06:36:38 2003
+++ Zope3/src/zope/publisher/http.py Mon Apr 28 09:14:21 2003
@@ -279,6 +279,7 @@
'_endswithslash', # Does the given path end with /
'method', # The upper-cased request method (REQUEST_METHOD)
'_locale', # The locale for the request
+ '_vh_root', # Object at the root of the virtual host
'_vh_trunc', # The number of path elements to be removed
# from _traversed_names
)
@@ -309,6 +310,7 @@
self.__setupPath()
self.__setupURLBase()
self._vh_trunc = 0
+ self._vh_root = None
self.response.setCharsetUsingRequest(self)
langs = BrowserLanguages(self).getPreferredLanguages()
@@ -439,6 +441,7 @@
if self._vh_trunc:
del self._traversed_names[:self._vh_trunc]
+ self._vh_trunc = 0
return ob
@@ -554,6 +557,10 @@
def setVirtualHostRoot(self):
self._vh_trunc = len(self._traversed_names) + 1
+ self._vh_root = self._last_obj_traversed
+
+ def getVirtualHostRoot(self):
+ return self._vh_root
URL = RequestDataProperty(URLGetter)