On 8/30/06, Lorenzo Gil Sanchez <[EMAIL PROTECTED]> wrote:
I guess I need to slightly change Zope publishing mechanism and I saw
IVirtualHostRoot in zope.publisher.interfaces.http. Probably calling
setVirtualHostRoot when the traversal is at 'site_folder' is what I need
but I have no clue about where should I do that.

You could register an event listener for
zope.app.publication.interfaces.IBeforeTraverseEvent, and manipulate
the request if event.object implements
zope.app.folder.interfaces.IRootFolder. You'll need a hack to find the
request though; you can get it from the security interaction:

from zope.publisher.interfaces.http import IHTTPRequest
from zope.security.management import getInteraction

def _getHTTPRequest():
   """Attempt to get the current request, if it exists"""
   interaction = getInteraction()
   if not interaction.participations:
   for participant in interaction.participations:
       if IHTTPRequest.providedBy(participant):
           return participant

That way you can detect the start of a request (before traverse event
on the root folder), grab the request, and manipulate it to suit your
virtual host needs.

Martijn Pieters
Zope3-users mailing list

Reply via email to