[Catalyst] Catalyst 5 Preview, Part 2

Sebastian Riedel sri at oook.de
Mon Apr 4 23:15:47 CEST 2005


We've been busy today fixing inheritance, and we've finally chosen a 
solution quite similar to Mason's autohandlers. :)


     package MyApp;

     sub begin : Private {}
     sub auto : Private { return 1 }
     sub end : Private {}

     package MyApp::C::Foo;

     sub auto : Private { return 1 }
     sub bar : Local {}
     sub end : Private {}

Now if you request http://localhost:3000/foo/bar/ Cat5 would process:

     MyApp->begin;

     MyApp->auto;
     MyApp::C::Foo->auto;
     MyApp::C::Foo->bar;

     MyApp::C::Foo->end;


So we have two built in actions (begin/end) and a processing chain in 
between.

auto is a new built in action which like Mason's autohandlers gets 
called before the requested action (bar).
They also have the ability to break the chain by returning 0, which is 
very useful for authentication and stuff.

begin and end are not chained, just overloadable.

Hope this wasn't too complicated, and you get an idea how things work.

Btw. default works equivalent to Mason dhandlers. ;)

--
sebastian




More information about the Catalyst mailing list