[Catalyst] why no $c->action_class ?

Dami Laurent (PJ) laurent.dami at justice.ge.ch
Wed Jul 16 14:47:43 BST 2008


Hi all,

Catalyst lets users build their own base classes for Request, Response,
Dispatcher , etc. (cf. methods $c->request_class, $c->dispatcher_class,
etc.).

Question : why is there no such mechanism for setting my own base class
for Action ?

I found a way to do it as follows :

    package My::App::Base::Controller;
    use My::App::Base::Action;
   __PACKAGE__->_action_class('My::App::Base::Action');

Another way would be to override the "register_actions" and/or
"create_action" method in My::App::Base::Controller.

However, both ways make me fell a bit uncomfortable because they rely on
Catalyst internals, not on any public API.

I know that there is a way to set action classes on a per-method basis,
by using the :ActionClass attribute, but it would be tedious to do this
on every method of every Controller. Furthermore, I want to keep the
:ActionClass mechanism for specific cases where I need a specific
subclass of My::App::Base::Action.

So, coming back to my question : is there any good reason why we don't
have a $c->action_class method in Catalyst ?

Thanks in advance,

	Laurent Dami









More information about the Catalyst mailing list