Hi,

Some time ago, I wrote:
Here's how to reproduce my problem:
> ...


And now, here comes how I've solved it. My solution forces nevow to think, that the request has been made for a given host and port. If that's not really the case, nevow will serve the Resource anyway - that's no different from not using the ForcedHost wrapper. Only in case nevow wants to issue a 301 redirect (due to addSlash=True), the forced host (and port) apply. Nevow will redirect to that host:port.


class ForcedHost(rend.Page):

        def __init__(self, res, host, port=80):
                self.wrappedResource = res
                self.host = host
                self.port = port

        def locateChild(self, ctx, segments):
                request = inevow.IRequest(ctx)
                request.setHost(self.host, self.port)
                return self.wrappedResource.locateChild(ctx, segments)

siteRoot = ForcedHost(MyNevowResource, 'www.my-forced-site.org')


Does anybody see any problems with this approach?

Regards

Markus

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to