[Catalyst] default template

Octavian Rasnita orasnita at gmail.com
Fri Dec 29 20:50:26 GMT 2006


Ok, I will read about RenderView.
I have discovered that I could use something like the following in the end 
subroutine:

$c->forward($c->view('TT')) unless $c->res->body or $c->res->redirect;

This way the end subroutine doesn't print anything and it doesn't need using 
the TT view if there is a redirection set.

I hope it is ok to do so, but I'll read more about RenderView.

Thanks.

Octavian

----- Original Message ----- 
From: "John Napiorkowski" <jjn1056 at yahoo.com>
To: "The elegant MVC web framework" <catalyst at lists.rawmode.org>
Sent: Friday, December 29, 2006 9:26 PM
Subject: Re: [Catalyst] default template


>
> --- Octavian Rasnita <orasnita at gmail.com> wrote:
>
>> Hi,
>>
>> I often need to make external redirections like in
>> the following case:
>>
>> sub logout : Local {
>> my ($self, $c) = @_;
>> $c->logout;
>> $c->res->redirect($c->uri_for("/"));
>> }
>>
>> When I access /user/logout for executing this
>> subroutine, it prints the
>> following error:
>>
>> Coldn't render template "file error - user/logout:
>> not found"
>>
>> So I need to add a template in the stash in this
>> subroutine, even though I
>> don't want to use and print any template, but just
>> do the redirect.
>>
>> If I add before redirection:
>>
>> $c->stash->{template} = "index.tt";
>>
>> all works fine, but I guess something is not right
>> in this code.
>>
>> Isn't there a way to just stop everything and make
>> the redirection, without
>> executing the end action?
>>
>> If it is not a way, isn't there a way to specify a
>> default template that's
>> used in these cases, for not needing to specify it
>> manually every time?
>>
>> I have seen that the order of the actions ran is:
>> /auto
>> /user/logout
>> /end
>> -> TranzactiiBursiere::View::TT->process
>>
>> Thank you.
>>
>> Octavian
>
> I had a similar problem.  The key thing to know is
> that using $c->response->redirect is just setting the
> HTTP headers for you, it isn't telling Catalyst to
> stop everything right there and then and process the
> response.  So your default end action is trying to
> process a template, but isn't finding one.  You need
> to either manually detect the redirect request in your
> end action and have it skip forwarding to the template
> toolkit view or use something like the Renderview
> action:
>
> http://search.cpan.org/~mramberg/Catalyst-Action-RenderView-0.04/lib/Catalyst/Action/RenderView.pm
>
> which will do that for you.
>
> If you look at the source code for that action you
> will gain a better understanding.
>
> --John
>
>>
>>
>> _______________________________________________
>> List: Catalyst at lists.rawmode.org
>> Listinfo:
>> http://lists.rawmode.org/mailman/listinfo/catalyst
>> Searchable archive:
>>
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
>> Dev site: http://dev.catalyst.perl.org/
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: 
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/ 




More information about the Catalyst mailing list