[Catalyst] url parsing and sub controller

Andreas Marienborg omega at palle.net
Mon Sep 5 22:22:27 CEST 2005


On 5. sep. 2005, at 18.00, Bernard FRIT wrote:

> Probably a dumb question ...
>
> I have a controller
> MyApp::C::Categ
>
> with
>
> sub default :  Private {
>     my ( $self, $c ) = @_;
>     $c->res->redirect('/default_action');
> }
>
> sub begin : Private {
>     my ( $self, $c , $categ) = @_;
>     if ($categ) {
>        $c->stash->{title} = "Category = $categ";
>        return 1;
>     }
> }
>
> when typing "domaine.tld /categ/MyCategory" I was expecting having
> $categ = MyCategory but I only have $categ=categ so I needed
>     my ( $self, $c , $dummy, $categ) = @_;
> to get the correct value. Is it correct behavior ?
>


Yes, as the default : Private actions are inheritable, and as such  
you need to make sure you use
the correct one. Think this has been debated before, atleast on IRC,  
but cannot remember what the outcome was.

basicly the third argument to default is an array with every path- 
element. So if you always want the last one, do my ($self, $c,  
@args); and pick out the last one. If you want a specific one, use  
that etc.

> More, I can't figure out why after executing begin, Catalyst execute
> default and redirect to "/default_action" ?
>


A log from the request would be mighty helpfull here, along with the  
table showing registered actions etc from the startup,

> --
> Bernard FRIT still unbrainedly trying to understand...
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>




More information about the Catalyst mailing list