[Catalyst] session in DB example in Catalyst book

Jonathan Rockway jon at jrock.us
Sun May 11 08:07:39 BST 2008

* On Sun, May 11 2008, Andrew wrote:
> And I'm doing everything exactly as the book states except the config change of putting the database path in the YAML file - it's still in the AddressDB.pm file.
> I looked in the DBIC.pm file which is generating the error message and the method that is causing the error is below:
> sub session_store_model {
>     my ($c, $id) = @_;
>     my $dbic_class = $c->session_store_dbic_class;
>     $c->model($dbic_class, $id) or die "Couldn't find a model named $dbic_class";
> }
> My question is where does $c->session_store_dbic_class come from?  Is it a class that I'm suppose to define or is it a class that is suppose to be included in the DBIC module?

This is just an internal method that implements the details of storing
session data with DBIx::Class.  (If you want the details, read the
Catalyst::Plugin::Session code, and see how it delegates to
Catalyst::Plugin::Session::Store and Catalyst::Plugin::Session::State.
Catalyst::Plugin::Session::Store::DBIC is the DBIC.pm that you are
referring to; its methods become $c->whatever when loaded into your app.
All Catalyst plugins currently work this way; all of their methods
become $c-> or YourApp-> methods as soon as you load them in the "use
Catalyst" line.)


I have a feeling that you are not following the book.  In Chapter 4, I
never call the database model "DBIC", I call it "AddressDB".  On page
60, I show the necessary configuration:

  AddressBook->config->(session => {
      dbic_class     => 'AddressDB::Session',
      flash_to_stash => 1,

You'll note that the word "DBIC" never appears in the program text, and
hence shouldn't be in error messages.  Are you sure that your
configuration is setup like the book.  Are you sure something in your
YAML file isn't overwriting this?

(If you look in the code bundle, you can find this in
chapter7-AddressBook/lib/AddressBook.pm.  Chapter 7 is just an extension
of Chapter 4, which for some reason isn't included in the tarball.  I
will probably update that in the next few days.  It makes sense to me,
but not anyone else :)

FWIW, later on in the book I call the model DBIC for the other
applications; I like this style better and I wrote those parts more
recently :)

Anyway, after you've checked that "DBIC" doesn't appear in your
configuration, let me know if it still doesn't work.

Jonathan Rockway

print just => another => perl => hacker => if $,=$"

More information about the Catalyst mailing list