[Catalyst] ACCEPT_CONTEXT with Module::Pluggable::Object

Cylon Toaster cylontoaster at gmx.de
Wed Oct 5 14:42:02 GMT 2011


in the book 'Guide to Catalyst' is described how to build a Driver Model 
using Module::Pluggable::Object.
You can find it on page 88, chapter 'A Driver Model for Generic 

All works fine :-)

But now I wanted to implement ACCEPT_CONTEXT, which always worked fine 
in 'normal' Models.
But when using 'Module::Pluggable::Object' and 'Class::MOP::load_class' 
the ACCEPT_CONTEXT-method is not invoked.

I'm not a Perl-Guru, so anybody can tell me how I could accomplish this?

It must have something to do with this driver-model, because when 
calling one of the loaded classes directly out of the controller, all 
works fine.

Here's a small excerpt of my code:

sub _build_collectors {
         my ($self) =@_;
         my $base = __PACKAGE__.'::Driver';

         my $mp = Module::Pluggable::Object->new(
                 search_path => [ $base ]
         my @classes = $mp->plugins;

         my %collectors;
         foreach my $class (@classes) {

                 unless ($class->does(OccSumDriver)) {
                         confess "Class ${class} in ${base}:: namespace 
does not implement Collection-Driver-Interface";

                 (my $name = $class) =~ s/^\Q${base}::\E//;
                 $collectors{$name} = $class->new;

         return \%collectors;

one of the loaded classes:

__PACKAGE__ ->mk_accessors(qw|context|);
         my ($self, $c, @args) = @_;
         return $self;


sub collect {
         my ($self, $arg_ref) = @_;

                 node_status => 'active',


thank u in advance,

More information about the Catalyst mailing list