[ZPT] page redirect

Tino Wildenhain tino@wildenhain.de
Tue, 27 Nov 2001 00:03:42 +0100


Hi,

--On Montag, 26. November 2001 14:53 -0200 Georges <georges@madisoncomunicacao.com.br> wrote:

> Hi,
>
> how can I "raise Redirect(url)"?
>
> ()s,
> Georges

In an Python Script.
Normally, the python way would be: raise Redirect(url)
But for this, Redirect has to be a subclass of Exception.
I think there are historical reasons why all the Zope Exceptions
are Strings (String Exceptions are deprecated since Python 1.4)

However, if you are not familar with the concept of exceptions
and classes, please consult the very good python manuals
at python.org. The tutorial does it clear out quite good.

In your case:

raise 'Redirect',url

would work.




>
> ----- Original Message -----
> From: "Tino Wildenhain" <tino@wildenhain.de>
> To: "Robert Rottermann" <robert@redcor.ch>; "Geir B=E6kholt"
> <geirh@funcom.com>; "Georges" <georges@madisoncomunicacao.com.br>
> Cc: <zpt@zope.org>
> Sent: Monday, November 26, 2001 4:11 PM
> Subject: Re: [ZPT] page redirect
>
>
> Hi,
>
> --On Monday, November 26, 2001 10:09:56 +0100 Robert Rottermann
> <robert@redcor.ch> wrote:
>
>> I wonder whether this is the right way to do it. Since tal is evaluated
>> before the page is displayed the page using such a redirect is never seen.
>
> This is a common mistake, acutally RESPONSE.redirect() sets only the headers
> (http status and location-header), but the page gets rendered normally.
> If one dont want this effect, (s)he has to use
> raise Redirect(url)
>
> For this or the other method - this is logic and should not take
> place in Templates anyway.
>
> Regards
> Tino
>
>> Robert
>> ----- Original Message -----
>> From: "Geir B=E6kholt" <geirh@funcom.com>
>> To: "Georges" <georges@madisoncomunicacao.com.br>
>> Cc: <zpt@zope.org>
>> Sent: Friday, November 23, 2001 7:28 PM
>> Subject: Re: [ZPT] page redirect
>>
>>
>>> Hello Georges,
>>> Friday, November 23, 2001, 19:03:24, you wrote:
>>> G>  how can I do a page redirect based in a condition using ZPT?
>>>
>>>
>>> you should be able to do something like (untested):
>>>
>>> <span tal:condition=3D"here/checksomething"
>>> tal:replace=3D"request.RESPONSE.redirect(URL)" />
>>>
>>> --
>>> Geir B=E6kholt                       web-developer
>>> geirh@funcom.com             funcom oslo | webdev-team
>>>
>>>
>>> _______________________________________________
>>> ZPT mailing list
>>> ZPT@zope.org
>>> http://lists.zope.org/mailman/listinfo/zpt
>>>
>>
>>
>> _______________________________________________
>> ZPT mailing list
>> ZPT@zope.org
>> http://lists.zope.org/mailman/listinfo/zpt
>
>
>
>
>
>