[Catalyst] Question about $c->forward()
Will Hawes
info at whawes.co.uk
Thu Nov 10 11:49:30 CET 2005
----- Original Message -----
From: Sebastian Riedel [mailto:sri at oook.de]
To: The elegant MVC web framework [mailto:catalyst at lists.rawmode.org]
Sent: Thu, 10 Nov 2005 09:47:27 +0000
Subject: Re: [Catalyst] Question about $c->forward()
> > Am 10.11.2005 um 10:37 schrieb Marcello:
> > > Will Hawes ha scritto:
> >> package My::C::First;
> >> use base 'Catalyst::Base';
> >> sub begin : Private {
> >> ...
> >> $c->forward('My::C::Second');
> >> }
> >> package My::C::Second;
> >> use base 'Catalyst::Base';
> >> sub default : Private {
> >> my ( $self, $c ) = @_;
> >> $c->forward('second');
> >> }
> >> sub second : Local {
> >> die 'ok';
> >> }
> >> In the above example, My::C::Second::second used to get called
> >> before upgrading to 5.49_02, now it doesn't. Catalyst now tries to
> >> forward to My::C::First::second, doesn't find it and dies with:
> >> Caught exception "My::C::Second did not override
> >> Catalyst::Component::process at C:/Perl/site/lib/Catalyst/
> >> Action.pm line 45"
> >
> > From my experience with Catalyst 5.23 and 5.33 this is the expected
> > behaviour.
> > That is, if you forward to a controller, that controller must
> > define its own "process" method. What would $c->forward
> > ('My::C::Second'); mean otherwise (i.e. what method of the package
> > My::C::Second should catalyst call) ?
> > Oh, right, there is a missing process() method, then this is exactly
> the expected behavior.
> > --
Apologies, I didn't include the second argument to forward() in My::C::First in my example. It should have read:
sub begin : Private {
my ( $self, $c ) = @_;
$c->forward('My::C::Second', 'default');
}
It's not this call to forward() that fails, it's the one in My::C::Second::default, which only works correctly if I use the two argument form of forward:
$c->forward('My::C::Second', 'second');
If I omit the controller name, I get the error mentioned earlier. But according to the docs, supplying just a method name to forward should result in that method being called in the current controller (which worked up to and including 5.33 as I mentioned). In this case that is not happening - Catalyst tries to call My::C::First::second rather than My::C::Second::second. So it is unsafe to pass a method name with no controller name to forward(), because it will break if you already forwarded from another controller in the same request.
I've just upgraded from trunk and am still seeing the same behaviour.
More information about the Catalyst
mailing list