[Zope-Checkins] CVS: Products/SiteAccess -
VirtualHostMonster.py:1.10.22.2
Evan Simpson
evan at 4-am.com
Fri Dec 12 14:36:40 EST 2003
Update of /cvs-repository/Products/SiteAccess
In directory cvs.zope.org:/tmp/cvs-serv32461/lib/python/Products/SiteAccess
Modified Files:
Tag: Zope-2_7-branch
VirtualHostMonster.py
Log Message:
Only one VirtualHostMonster is allowed per container.
When a VHM is activated, it adds the mapping 'VIRTUAL_URL_PARTS': (SERVER_URL, BASEPATH1, virtual_url_path) to the request's 'other' dictionary. If BASEPATH1 is empty, it is omitted from the tuple. The joined parts are also added under the key 'VIRTUAL_URL'. Since the parts are evaluated before traversal continues, they will not reflect modifications to the path during traversal or by the addition of a default method such as 'index_html'.
=== Products/SiteAccess/VirtualHostMonster.py 1.10.22.1 => 1.10.22.2 ===
--- Products/SiteAccess/VirtualHostMonster.py:1.10.22.1 Mon Nov 17 17:34:11 2003
+++ Products/SiteAccess/VirtualHostMonster.py Fri Dec 12 14:36:39 2003
@@ -7,6 +7,7 @@
from OFS.SimpleItem import Item
from Acquisition import Implicit, aq_inner, aq_parent
from ZPublisher import BeforeTraverse
+from zExceptions import BadRequest
import os
from AccessRule import _swallow
@@ -98,7 +99,6 @@
def addToContainer(self, container):
container._setObject(self.id, self)
- self.manage_afterAdd(self, container)
def manage_addToContainer(self, container, nextURL=''):
self.addToContainer(container)
@@ -113,6 +113,10 @@
def manage_afterAdd(self, item, container):
if item is self:
+ if BeforeTraverse.queryBeforeTraverse(container,
+ self.meta_type):
+ raise BadRequest, ('This container already has a %s' %
+ self.meta_type)
id = self.id
if callable(id): id = id()
@@ -127,6 +131,7 @@
'''Traversing at home'''
vh_used = 0
stack = request['TraversalRequestNameStack']
+ path = None
while 1:
if stack and stack[-1] == 'VirtualHostBase':
vh_used = 1
@@ -138,6 +143,7 @@
request.setServerURL(protocol, host, port)
else:
request.setServerURL(protocol, host)
+ path = list(stack)
# Find and convert VirtualHostRoot directive
# If it is followed by one or more path elements that each
@@ -153,12 +159,15 @@
for jj in range(vh, ii):
pp.insert(1, stack[jj][4:])
stack[vh:ii + 1] = ['/'.join(pp), self.id]
+ ii = vh + 1
elif ii > 0 and stack[ii - 1][:1] == '/':
pp = stack[ii - 1].split('/')
stack[ii] = self.id
else:
stack[ii] = self.id
stack.insert(ii, '/')
+ ii += 1
+ path = stack[:ii]
# If the directive is on top of the stack, go ahead
# and process it right away.
if at_end:
@@ -169,6 +178,18 @@
vh = ii
if vh_used or not self.have_map:
+ if path is not None:
+ path.reverse()
+ vh_part = ''
+ if path and path[0].startswith('/'):
+ vh_part = path.pop(0)[1:]
+ if vh_part:
+ request['VIRTUAL_URL_PARTS'] = vup = (
+ request['SERVER_URL'], vh_part, '/'.join(path))
+ else:
+ request['VIRTUAL_URL_PARTS'] = vup = (
+ request['SERVER_URL'], '/'.join(path))
+ request['VIRTUAL_URL'] = '/'.join(vup)
return
vh_used = 1 # Only retry once.
# Try to apply the host map if one exists, and if no
More information about the Zope-Checkins
mailing list