[Catalyst] Cascading action dispatching

Matthew Pitts mpitts at a3its.com
Sun Oct 21 15:20:20 GMT 2007

On Fri, 2007-10-19 at 17:16 -0400, Matthew Pitts wrote:
> I'm trying to figure out a way to have my Cat app dispatch in a way
> that
> would allow multiple actions in the same namespace and have them
> called
> in succession until one of them actually handles the request.
> I have a client that really likes base-level URLs, like
> "/shoppingmallxyz", and wants to use them for landing pages that are
> functionally different. In some of these cases the base-level URL
> paths
> are really just monikers for things that are retrieved from the DB and
> if it exists, then a page is rendered.

I guess another, maybe more elegant, way to accomplish this same effect
would be to override register_actions in the Controllers where I want to
do this and have a call to a register_dynamic_actions method like so:

package MyApp::Controller::Center;

sub register_actions {
    my $self = shift;
    my ( $c ) = @_;


    return $self->SUPER::register_actions(@_);    # or NEXT?

sub register_dynamic_actions {
    my $self = shift;
    my ( $c ) = @_;

    my $centers = $c->model('Center')->all;

    while ( my $center = $centers->next ) {
        my $action = $self->create_action(...);
        $c->dispatcher->register($c, $action);


An obvious side-effect (AFAIK) of doing it this way is that the app has
to be restarted for new dynamic actions to take affect. The benefit,
however, is that the root-level pseudo-actions I was trying to achieve
with on-the-fly DB lookups are now first class actions and would not
require a DB call on each request.

I may be crazy... anybody got any thoughts on this?

Matthew W. Pitts
Software Engineer
mpitts at a3its.com
336.202.3913 (mobile)

A3 IT Solutions, LLC

More information about the Catalyst mailing list