[Catalyst] Still Confused

Sebastian Riedel sri at oook.de
Fri Apr 8 22:33:33 CEST 2005


Am 08.04.2005 um 21:59 schrieb Chisel Wright:

> I'm working with v5 at the moment, primarily because that's what the
> mojomojo app I was pointed at seems to use [based on use of subs with
> attributes].
>
> I've managed to confuse myself again, I've done the following:
>
>  catalyst.pl Magic
>  cd Magic
>  ./script/create.pl controller Trick
>
> I've tweaked lib/Magic.pm to:
>
>   sub default : Private {
>     my ( $self, $c ) = @_;
> 	$c->forward( '/trick' );
>   }
>
>   sub trick : Private {
>     my ( $self, $c ) = @_;
> 	$c->res->output(__PACKAGE__ . ' : trick');
>   }
>
> Then I tried:
>
>   ./script/test.pl
>   [snippage]
>   .=-----------------------
>   | Action
>   |=-----------------------
>   | -> /trick
>   | /default
>   '=-----------------------
>
>   Magic : trick
>
>
> followed by
>
>   ./script/test.pl /trick
>   [snippage]
>   .=-----------------------
>   | Action
>   |=-----------------------
>   | /trick/default
>   '=-----------------------
>
> Congratulations, Magic::C::Trick is on Catalyst!
>
>
> This is where my fundamental misunderstanding of everything starts to
> become apparent ...
>
> What should I do to be forwarded to Magic::C::Trick when I visit, well
> anything that's not a /trick URI already.
>
> I would have expected forward('trick') to use the lib/Magic.pm->trick()
> function, and forward('/trick') to be treated the same way as
> ./script/test.pl /trick
>
>
> I've tried to work this out, but for some reason I just can't get the
> right incantations through my keyboard at the moment.

It works perfectly right! :)

You defined   "sub trick : Private" which means that it's only 
available for forwarding!
Try "sub trick : Local" or "sub trick : Global". ;)

--
sebastian




More information about the Catalyst mailing list