[Zope] RESPONSE.redirect in Python Script?
Walter Miller
wmiller@macromedia.com
Fri, 9 Feb 2001 08:24:58 -0800
It turns out that the only way to do a redirect in an Access Rule is through
a raise redirect since the return value of an Access Rule is ignored. So,
again thanks to Evan for this nugget, here's the way to a redirect in a
Python Script-based Access Rule:
if host == 'foo.com':
raise 'Redirect', 'http://www.foo.com'
> On Friday 09 February 2001 11:44, Walter Miller wrote:
> > I get this error:
> >
> > Error Type: NameError
> > Error Value: RESPONSE
> >
> >
> > I'm actually trying to do this in an Access Rule to be used
> along with a
> > VHM (much thanks to Evan for helping me get that set up).
> The code goes
> > something like this:
> >
> > """
> > host = req['HTTP_HOST']
> > stack = req['TraversalRequestNameStack']
> >
> > if host == 'www.foo.com':
> > stack.extend(['VirtualHostRoot', 'foo', 'vhosts'])
> > elif host == 'foo.com':
> > return RESPONSE.redirect('http://www.foo.com')
> > """
> >
> > BTW, I'm using 2.3.0 on FreeBSD 4.2
> >
>
> What parameters are you passing to the method? I am not
> familiar with the
> details of VHM...
>
> If you are not passing RESPONSE, but are passing REQUEST, you can get
> REQUEST.RESPONSE.redirect()
>
> otherwise, life gets interesting.... and you have to go ask
> someone else.. (o8
>
>
> Have a better one,
> Curis Maloney
>