Lorenzo Gil Sanchez wrote:
> 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:
> 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
> 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.
Write a custom traversal adapter:
from zope.interface import implementsOnly
from zope.component adapts
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.app.container.interfaces import IContainer
from zope.app.container.traversal import ItemTraverser
"""We assume that the roots of virtual hosts are containers"""
def publishTraverse(self, request, name):
<adapter factory=".VirtualHostRootTraverse" permission="zope.Public" />
Untested, no warranties.
Zope3-users mailing list