[Catalyst] Multiple inheritance of controllers

Byron Young Byron.Young at riverbed.com
Fri Jun 13 23:24:31 BST 2008


I ran into the same problem.  But I found that adding this to my controllers that inherit from multiple controller base classes works as a work around:

use Class::C3;

sub create_action {
    my $self = shift;

    return $self->maybe::next::method(@_);
}

It's an annoying workaround, but I didn't have time to pursue the issue any further :P  Does anybody know why this might be happening?

Anyway, I hope that helps somewhat..

Byron


Zbigniew Lukasiak wrote on 2008-06-13:
> I've tried to build a module that would merge two base controllers and
> then use it as another base controller.  Unfortunately it looks like
> only actions from the first base class in the 'use base ...' phrase are
> being inherited:
>
> I've created a test case for that - it is attached and I paste it
> below for your convenience.
>
> If someone sent me some instructions how to modify it to fit into the
> Moose model I'll test it on the Moose branch as well (I am not sure if
> they would be base controllers there at all - perhaps Roles instead?).
>
> Cheers,
> Zbigniew
>
>
> package TestApp::Controller::Action::SubclassedChained;
> use strict;
> use warnings;
>
> use base qw/Intermediate/;
> 1;
>
> ==================================================================
> package Intermediate; use strict; use warnings;
>
> use base qw/Catalyst::Controller::REST Base/;  # this one does not
> inherit actions from Base
> #use base qw/Base Catalyst::Controller::REST/; # this one does
>
> 1; ==================================================================
> package Base; use strict; use warnings;
>
> use base qw/Catalyst::Controller/;
>
> sub basefoo  :CaptureArgs(1) :Chained('/') { }
> sub baseendpoint :Args(1) :Chained('basefoo') { }
> 1;
>
>
>
> --
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/
> http://perlalchemy.blogspot.com/




More information about the Catalyst mailing list