[Catalyst] Has $c->response->redirect behaviour changed?
Alex Kavanagh
alex at tinwood.homelinux.org
Mon Jan 23 20:07:11 CET 2006
Okay, my own follow-up:
At Mon, 23 Jan 2006 14:24:31 +0000,
Alex Kavanagh wrote:
>
> Hi
>
> I just upgraded from 5.61 to 5.63 and I got a strange error with one
> of my HTML::Mason templates that complained about a variable not being
> defined.
>
> The difference between the two seems to be that in 5.61 the view was
> NOT processed when a redirect was issued, but now with 5.62 the view
> IS processed and therefore it tripped up my view.
>
> In my case the very simple change from:
>
> $c->response->redirect('/manage/users/' . $obj->username );
>
> to:
>
> $c->stash->{form} = { field => $field };
> $c->response->redirect('/manage/users/' . $obj->username );
>
> allowed the Mason view to process (i.e. needed the form in the stash).
>
> The reason I question this is that the processed view will never be
> displayed due to the redirect.
>
> Is this any of the following:
>
> a) a buggy install?
> b) a change in behaviour?
> c) a bug that has been introduced?
> d) Have I been relying on a 'feature' that I shouldn't have?
I've fixed it by over-riding 'process' in the Mason View as follows:
=head2 process
Overload process to not do the template if we are doing a redirect.
=cut
sub process {
my $self = shift;
my $c = shift;
my $status = $c->response->status;
if (($status =~ /^(\d)\d\d$/) &&
($1 == 3)) {
# Don't bother processing if we are doing a redirect
return 1;
}
return $self->SUPER::process($c, @_);
}
It works, but is the right way to do it? Should I be doing something
else?
Many thanks
Alex.
More information about the Catalyst
mailing list