Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Catalyst request handling

by redlemon (Hermit)
on Nov 22, 2005 at 15:44 UTC ( #510833=perlquestion: print w/replies, xml ) Need Help??
redlemon has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks, I'm starting with Catalyst and I'm confused at the moment about how catalyst handles my request.

Basically I ran: Greet; cd Greet scripts/ view TT TT scripts/ controller Greeting echo "[% greeting %]" > root/

And edited 'lib/Greet/C/' so it looks like this:

sub default : Private { my ( $self, $c ) = @_; $c->forward('say'); } sub say : Local { my ( $self, $c ) = @_; $c->stash->{greeting} = join q{, }, @{ $c->req->args() }; $c->stash->{template} = q{}; $c->forward('Greet::V::TT'); }

Now running a couple of scenarios, I get:

1. scripts/ / -> Congratulations, Greet is on Catalyst! 2. scripts/ /greeting/say/hello/world -> hello, world 3. scripts/ /greeting/hello/world -> greeting, hello, world 4. scripts/ /hi/there/greeting/say/hello/world -> hi, there, greeting, say, hello, world

Now, scenario 1 is as expected. I didn't change the main file and it presents the default blurb.

Scenario 2 is also as expected, I run the controller with the say request and it answers me back with the arguments.

But what about scene 3? Why didn't that strip the namespace from the arguments? And I'm really confused about scene 4. I would have expected that to print the same as 1.

Can someone explain this behaviour to me?


Replies are listed 'Best First'.
Re: Catalyst request handling
by Anonymous Monk on Nov 22, 2005 at 17:09 UTC
    Scene 3 does that because default doesn't work that way. If you wanted the namespace stripped then you'd do something like
    sub base :Path('') {

    which will be a path action anchored at /greeting and as such should see args of ('hello', 'world').
    Scene 4, I'm not entirely sure - I wonder if there's a default in your app class picking up the result or similar ...
    - Matt S Trout (mst on

      Thanks, your 'base()' suggestion does work indeed.

      There's nothing else in any of the files than whatI described in my question. However, in the mean time I've upgraded to Catalyst 5.57, which does behave as expected. So I guess it was a bug in an earlier version.

      Thanks for explaining.

Re: Catalyst request handling
by chibiryuu (Beadle) on Nov 22, 2005 at 18:13 UTC
    sub default : Private { my ( $self, $c ) = @_; my (undef, @args) = @{$c->req->args}; $c->forward('say', \@args); }
    This make scene 3 behave the way you expect it to.

    But I can't reproduce your scene 4.  (Catalyst 5.56 here.)  Do you have a $c->forward in

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://510833]
Approved by friedo
Front-paged by kutsu
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-05-25 19:16 GMT
Find Nodes?
    Voting Booth?