I'm playing with a hand-crafted model using Catalyst::Model::DBI and DBIx::Simple. In one of the methods I create a $dbi object as DBIx::Simple->new($self->dbh), and then stuff $dbi into the $self->context->stash for use elsewhere in the model methods, and all is well.

But if that particular method isn't called by a Controller, then the DBIx::Simple object isn't created and subsequent methods fail. I thought I ought to be able to do something like this at the top instead:

package MyApp::Model::DBI;

__PACKAGE__->config(
  dbi => DBIx::Simple->new(__PACKAGE__->dbh),
);

but obviously not:
Can't use string ("MyApp::Model::DBI") as a HASH ref while "strict refs" in use at /usr/local/share/perl/5.8.7/Class/Accessor/Fast.pm line 38.

MyApp::Model::DBI connect_info is automatically loaded from the global config file. I need to get the models dbh into DBIx::Simple->new(). What am I doing wrong?
--
Richard Jones

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to