[Catalyst] C::Compontent::InstancePerContext
Steve
steve at matsch.com
Mon Nov 15 22:18:12 GMT 2010
Hello all,
I'm hoping someone can help me with C:C:IPC. I need my application to
authenticate
against one database, then use $c->user->dsn after authentication to
connect to that
customer's application database. I've been digging through docs and the
code in
C:C:IPC as well as ACCEPT_CONTEXT (which I haven't used 'cuz I was told
not to).
Here's what I have:
package MyApp::Model::mps;
use base 'Catalyst::Model::DBIC::Schema';
with 'Catalyst::Component::InstancePerContext';
has 'context' => (is => 'ro');
sub build_per_instance_context {
my ($self, $c) = @_;
my $dsn = $c->user->get_dsn; # returns 'dbi:mysql:DBNAME'
$self->config( connect_info => {'dsn' => $dsn} ); # this sets config
correctly
return $self->new({context => $c, %$self});
}
Using the debugger, I verified that $self->config is set properly,
however when
the call to $self->new tries to execute, I can see that
$self->connect_info did
not get set, and therefor I get lots of nasty messages that start like:
Subroutine cms_p::Model::mps::Reqsubcarrsfitem::ACCEPT_CONTEXT redefined
at /usr/lib/perl5/site_perl/5.8.8/Catalyst/Model/DBIC/Schema.pm line 542.
at /usr/lib/perl5/site_perl/5.8.8/Catalyst/Model/DBIC/Schema.pm line 542
Catalyst::Model::DBIC::Schema::_install_rs_models('cms_p::Model::mps=HASH(0xd1f0a78)')
called at /usr/lib/perl5/site_perl/5.8.8/Catalyst/Model/DBIC/Schema.pm
line 495
Catalyst::Model::DBIC::Schema::BUILD('cms_p::Model::mps=HASH(0xd1f0a78)', 'HASH(0xd1f6640)')
called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Class/MOP/Method.pm
line 123
Class::MOP::Method::execute('Moose::Meta::Method=HASH(0xbd32024)',
'cms_p::Model::mps=HASH(0xd1f0a78)', 'HASH(0xd1f6640)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Object.pm
line 50
Moose::Object::BUILDALL('cms_p::Model::mps=HASH(0xd1f0a78)',
'HASH(0xd1f6640)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Meta/Class.pm
line 278
Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0xbd10604)',
'HASH(0xd1f6640)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Object.pm
line 25
Moose::Object::new('cms_p::Model::mps', 'HASH(0xbd15f80)')
called at generated method (unknown origin) line 3
Catalyst::Model::DBIC::Schema::new('cms_p::Model::mps=HASH(0xac695f8)',
'HASH(0xbd15f80)') called at
/home/steve/Catalyst/cms_p/script/../lib/cms_p/Model/mps.pm line 27
cms_p::Model::mps::build_per_context_instance('cms_p::Model::mps=HASH(0xac695f8)',
'cms_p=HASH(0xd062244)') called at
/usr/lib/perl5/site_perl/5.8.8/Catalyst/Component/InstancePerContext.pm
line 24
Catalyst::Component::InstancePerContext::ACCEPT_CONTEXT('cms_p::Model::mps=HASH(0xac695f8)',
'cms_p=HASH(0xd062244)') called at
/usr/lib/perl5/site_perl/5.8.8/Catalyst.pm line 614
Catalyst::_filter_component('cms_p=HASH(0xd062244)',
'cms_p::Model::mps=HASH(0xac695f8)') called at
/usr/lib/perl5/site_perl/5.8.8/Catalyst.pm line 685
Catalyst::model('cms_p=HASH(0xd062244)', 'mps') called at
/usr/lib/perl5/site_perl/5.8.8/Catalyst/Model/DBIC/Schema.pm line 540
...
Can anyone lend a hand?
Thanks,
Steve
More information about the Catalyst
mailing list