[Catalyst] Catalyst 5 preview!

Sebastian Riedel sri at oook.de
Thu Mar 31 18:58:52 CEST 2005


Am 31.03.2005 um 18:24 schrieb Alan Humphrey:

> Looks good to me.  I like how it makes things clearer.
>
> Two questions:
>
> 1) what is the difference between Global and Local?  When would I use
> one vs. the other vs. Path?

Marcus already updated the Manual but i'll explain it here too...

     package MyApp::C::Foo;

     # http://localhost:3000/bar
     sub bar : Global {}

The Global flag makes Cat use the method name in the global namespace 
(/).

     package MyApp::C::Foo;

     # http://localhost:3000/foo/bar
     sub bar : Local {}

The Local flag makes Cat use the method name in the local namespace 
(/foo).

     package MyApp::C::Foo;

     # http://localhost:3000/yada/bar
     sub bar : Path('/yada/bar')

The Path flag is used when the action name can't be expressed as method 
name.

     package MyApp::C::Foo;

     # http://localhost:3000/foo/yada/bar
     sub bar : Path('yada/bar')

It can be absolute like in the first example or relative to the actual 
namespace like here.

It's a very clean and simple concept.


> 2) will argument passing via the URL still be accomplished only via
> regex?

It never was...
All actions have arguments!

     sub foo : Global {
         my ( $self, $c, $arg1, $arg2, $arg3...) = @_;

The only thing exclusive to Regex are snippets.

--
sebastian




More information about the Catalyst mailing list