[Catalyst] Dispatching based on path and host/domain

Matt S Trout dbix-class at trout.me.uk
Wed Apr 23 20:32:04 BST 2008


On Wed, Apr 23, 2008 at 03:25:47PM +0100, Curtis Fletcher wrote:
> > -----Original Message-----
> > From: Matt S Trout [mailto:dbix-class at trout.me.uk] 
> > Sent: 23 April 2008 14:34
> > To: The elegant MVC web framework
> > Subject: Re: [Catalyst] Dispatching based on path and host/domain
> > 
> > :Local is a shortcut for 
> > :Path($controller->path_prefix.'/'.$method_name)
> > 
> > Those values came straight off the attributes - you'd set the 
> > Domain key
> > just by using :Domain('foobar.com') exactly as you did in 
> > your original
> > example (which is where I got the key name from :)
> 
> And the light comes on because someone is finally home!
> I was thinking that :Local :Path etc were shortcuts to defining an
> ActionClass not attributes to the (mostly) default ActionClass. Bingo it
> all makes sense now. Many thanks.

Right. The ActionClass affects how the action itself gets to make its choices.

Things like :Path and :Chained indicate that whatever aciton object is
constructed should be registered with a particular dispatch type.

We just happen to only have one attribute namespace because that's how many
perl has :)
 
> Digging around, is it a sane thing to have:
> 
> __PACKAGE__->_action_class('Catalyst::Action::MyAction');
> 
> At the top of a controller if I want all of the methods to use the same
> non-default ActionClass? I'm nervous about using anything that starts
> with _

It starts with _ because you should never call it from -outside- the class.

You're fine calling it on your own class.

Doc patch to make this clear very welcome.
 
> On a related note: While I was looking for information about setting a
> default ActionClass I came across the ActionClass info in
> http://search.cpan.org/~mstrout/Catalyst-Manual-5.701004/lib/Catalyst/Ma
> nual/ExtendingCatalyst.pod I wish I'd found that at the start, maybe
> I'll put together a patch for the Catalyst::Action and
> Catalyst::Manual::Actions pod that points people back there for info
> about using "match" (does that sound like a good thing to do?)

Yes please!

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list