[Zope3-Users] Virtual hosting problem

2006-08-30 Thread Lorenzo Gil Sanchez
Hi,

I know Zope3 has great support for virtual hosting and you can easily
set it up using the Rewrite module of Apache as described here:

http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/virtualhosting.html

My problem is that my hosting provider does not allow me to create
custom rewrite rules so I need to do the same in Zope3 side.

Basically I want to change all request with the form
http://www.mysite.com/$1 to http://localhost:8080/site_folder/++vh
++http:www.mysite.com:80/++$1

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.

Any help?

Thanks in advance

Lorenzo

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Virtual hosting problem

2006-08-30 Thread Martijn Pieters

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:
   return
   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
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users