[Catalyst] InstancePerContext doesn't work in schema

Steve Kleiman steve at prodhub.com
Wed Jan 13 22:04:37 GMT 2010


Having trouble with InstancePerContext in a schema. I'd like to be able to get at $c from within a schema definition. The $callsheet->context call does not throw an error and returns an undef value. So in the case below, I would expect console output to be 'good test' but instead I get "Can't call method "log" on an undefined value".

Thanks in advance for any guidance.

Steve Kleiman


> package Prodhub::Schema::Data::Project::CallsheetDB;
> 
> use strict;
> use warnings;
> 
> use base qw|DBIx::Class|;
> # use base qw|DBIx::Class Catalyst::Component::ACCEPT_CONTEXT|;
> use Moose;
> with 'Catalyst::Component::InstancePerContext';
> has 'context' => (is => 'ro');
> 
> sub build_per_context_instance {
> 	my ($self, $c, @args) = @_;
> 	return $self->new({ context => $c, %$self, @args });
> }
> 
> sub test {
> 	my ( $callsheet ) = @_;
> 	$callsheet->context->log->debug("good test");
> }




More information about the Catalyst mailing list