[Zope] redirecting from within an access rule

Zopista zopista@zopezen.org
Thu, 21 Jun 2001 23:33:33 -0700


Read the minor notes at the bottom of the Site Access docs:
http://www.zope.org/Members/4am/SiteAccess2/vhosting

"The return value of an Access Rule is ignored and discarded. This allows
embedded string comments such as in the examples above, and the use of
<dtml-return " 'ignored' "> to exit the Rule. It also means that if you want
to redirect within an Access Rule, you must use <dtml-raise type="Redirect">
instead of "RESPONSE.redirect()"

Cheers

----- Original Message -----
From: "tav" <tav@espnow.com>
To: <zope@zope.org>
Sent: Thursday, June 21, 2001 10:32 PM
Subject: [Zope] redirecting from within an access rule


> hi there
>
> i am trying to set up an access rule, so that requests to different
domains
> will be redirected to the "default" domain. e.g.
> http://www.espra.com/foo/bar would redirect to http://espra.net/foo/bar,
> where "espra.net" is the default domain.
>
> to do this, i have a TinyTable (redirect_index) setup:
>
> ----------------------------------
> | host_name, redirect_to
> ----------------------------------
> | "espra.org", "espra.net"
> | "espra.com", "espra.net"
> | "www.espra.org", "espra.net"
> | "www.espra.net", "espra.net"
> | "www.espra.com", "espra.net"
> ----------------------------------
>
> and an access rule:
>
> <dtml-in "redirect_index(HTTP_HOST)">
>   <dtml-unless "redirect_to == ''">
>     <dtml-let to_new_url="_.string.replace(URL0,HTTP_HOST,redirect_to)">
>       <dtml-call "REQUEST.RESPONSE.redirect(to_new_url)">
>     </dtml-let>
>   </dtml-unless>
> </dtml-in>
>
> i had hoped that the above would redirect to the "default" domain, if it
> found any of the other domains, in the TinyTable
>
> however, the redirect doesn't seem to work as expected within an
AccessRule.
> it redirects all urls to http://espra.net irrespective of the part after
the
> server url
>
> e.g. http://www.espra.com/foo/bar would redirect to http://espra.net
instead
> of redirecting to http://espra.net/foo/bar
>
> so.... what exactly am i doing wrong here?
>
> --
> best regards, tav
> tav@espnow.com
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>