On Wed, Jul 16, 2008 at 03:47:43PM +0200, Dami Laurent (PJ) wrote: > 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 ?
Yes. It's per-controller. The two methods you already described are correct. _action_class is _prefixed to indicate it shouldn't be called from outside the class, not that you shouldn't override it. register_actions and create_action are both not prefixed because they're not only meant to be wrapped but callable from outside the object. If you feel that this isn't clear, a doc patch would be much appreciated. -- 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/ _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/