Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

session in DB example in Catalyst book

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


archan2000 at yahoo

May 9, 2008, 6:53 PM

Post #1 of 11 (332 views)
Permalink
session in DB example in Catalyst book

Using the Rockway's Catalyst book to help bring me up to speed on Catalyst and I've got a problem that I can't figure out.

On page 59, where it uses a database to store the session key, I've made all the code changes, but when I start the server it gives me the following error:

"Couldn't find a model named DBIC::Session at /usr/local/share/perl/5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.
Compilation failed in require at script/addressbook_server.pl line 53."

I've installed Session::Store::DBIC module and even reinstalled it to see if missed out on the Session model and I get the same error. Any ideas?


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


diment at gmail

May 9, 2008, 7:30 PM

Post #2 of 11 (322 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

On 10 May 2008, at 11:53, Andrew wrote:

> Using the Rockway's Catalyst book to help bring me up to speed on
> Catalyst and I've got a problem that I can't figure out.
>
> On page 59, where it uses a database to store the session key, I've
> made all the code changes, but when I start the server it gives me
> the following error:
>
> "Couldn't find a model named DBIC::Session at /usr/local/share/perl/
> 5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.
> Compilation failed in require at script/addressbook_server.pl line
> 53."
>
> I've installed Session::Store::DBIC module and even reinstalled it
> to see if missed out on the Session model and I get the same
> error. Any ideas?
>

Two things you need to look at:

1. The example code for the book at:

http://jrock.us/Catalyst-Book-Code-20080131.tar.gz

2. The book errata (use the community errata, not the Packt errata)

http://catwiki.toeat.com/thebookerrata

If you're still having problems after looking at them thoroughly,
come back and ask more.

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


archan2000 at yahoo

May 9, 2008, 8:41 PM

Post #3 of 11 (321 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

Got all those resources, checked my code and same thing.

--- On Fri, 5/9/08, Kieren Diment <diment[at]gmail.com> wrote:
From: Kieren Diment <diment[at]gmail.com>
Subject: Re: [Catalyst] session in DB example in Catalyst book
To: archan2000[at]yahoo.com, "The elegant MVC web framework" <catalyst[at]lists.scsys.co.uk>
Date: Friday, May 9, 2008, 7:30 PM

On 10 May 2008, at 11:53, Andrew wrote:

> Using the Rockway's Catalyst book to help bring me up to speed on
> Catalyst and I've got a problem that I can't figure out.
>
> On page 59, where it uses a database to store the session key, I've
> made all the code changes, but when I start the server it gives me
> the following error:
>
> "Couldn't find a model named DBIC::Session at
/usr/local/share/perl/
> 5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.
> Compilation failed in require at script/addressbook_server.pl line
> 53."
>
> I've installed Session::Store::DBIC module and even reinstalled it
> to see if missed out on the Session model and I get the same
> error. Any ideas?
>

Two things you need to look at:

1. The example code for the book at:

http://jrock.us/Catalyst-Book-Code-20080131.tar.gz

2. The book errata (use the community errata, not the Packt errata)

http://catwiki.toeat.com/thebookerrata

If you're still having problems after looking at them thoroughly,
come back and ask more.


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


omega at palle

May 9, 2008, 10:19 PM

Post #4 of 11 (320 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

On May 10, 2008, at 3:53 AM, Andrew wrote:

> Using the Rockway's Catalyst book to help bring me up to speed on
> Catalyst and I've got a problem that I can't figure out.
>
> On page 59, where it uses a database to store the session key, I've
> made all the code changes, but when I start the server it gives me
> the following error:
>
> "Couldn't find a model named DBIC::Session at /usr/local/share/perl/
> 5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.
> Compilation failed in require at script/addressbook_server.pl line
> 53."

You don't seem to have the Model you configured the session store to
use. Do you have the MyApp/Model/DBIC/Session.pm file?


- andreas


archan2000 at yahoo

May 10, 2008, 1:50 AM

Post #5 of 11 (315 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

The only Session.pm is found in /AddressBook/Schema. I don't have Models for the People or Addresses that I'm retrieving in this address book example, but I've only got Schemas and Controllers.

The code of /AddressBook/Schema/Session.pm is and as you can see by the package designation Session.pm is suppose to be under the Schema directory and not the Model directory.
--------------------------------
package AddressBook::Schema::AddressDB::Session;

use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->table('sessions');
__PACKAGE__->add_columns(
id => { data_type => "CHAR", is_nullable => 0, size => 72 },
session_data => { data_type => "TEXT", is_nullable => 1, size => undef },
expires => { data_type => "INTEGER", is_nullable => 1, size => undef}
);
__PACKAGE__->set_primary_key('id');
1;
-----------------------------------

--- On Fri, 5/9/08, Andreas Marienborg <omega[at]palle.net> wrote:
From: Andreas Marienborg <omega[at]palle.net>
Subject: Re: [Catalyst] session in DB example in Catalyst book
To: archan2000[at]yahoo.com, "The elegant MVC web framework" <catalyst[at]lists.scsys.co.uk>
Date: Friday, May 9, 2008, 10:19 PM


On May 10, 2008, at 3:53 AM, Andrew wrote:
Using the Rockway's Catalyst book to help bring me up to speed on Catalyst and I've got a problem that I can't figure out.

On page 59, where it uses a database to store the session key, I've made all the code changes, but when I start the server it gives me the following error:

"Couldn't find a model named DBIC::Session at /usr/local/share/perl/5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.
Compilation failed in require at script/addressbook_server.pl line 53."

You don't seem to have the Model you configured the session store to use. Do you have the MyApp/Model/DBIC/Session.pm file?

- andreas


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


dbix-class at trout

May 10, 2008, 8:04 AM

Post #6 of 11 (314 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

On Fri, May 09, 2008 at 06:53:47PM -0700, Andrew wrote:
> <table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'>Using the Rockway's Catalyst book to help bring me up to speed on Catalyst and I've got a problem that I can't figure out.<br><br>On page 59, where it uses a database to store the session key, I've made all the code changes, but when I start the server it gives me the following error:<br><br>"Couldn't find a model named DBIC::Session at /usr/local/share/perl/5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.<br>Compilation failed in require at script/addressbook_server.pl line 53."<br><br>I've installed Session::Store::DBIC module and even reinstalled it to see if missed out on the Session model and I get the same error.&nbsp; Any ideas?<br></td></tr></table><br>
>
> <hr size=1>Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a>
>

You're posting in HTML only.

Fix your mail client.

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

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


jon at jrock

May 10, 2008, 6:43 PM

Post #7 of 11 (297 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

* On Sat, May 10 2008, Andreas Marienborg wrote:
> On May 10, 2008, at 3:53 AM, Andrew wrote:
>
>
> Using the Rockway's Catalyst book to help bring me up to speed on Catalyst
> and I've got a problem that I can't figure out.
>
> On page 59, where it uses a database to store the session key, I've made
> all the code changes, but when I start the server it gives me the following
> error:
>
> "Couldn't find a model named DBIC::Session at /usr/local/share/perl/5.8.8/
> Catalyst/Plugin/Session/Store/DBIC.pm line 143.
> Compilation failed in require at script/addressbook_server.pl line 53."
>
>
> You don't seem to have the Model you configured the session store to use. Do
> you have the MyApp/Model/DBIC/Session.pm file?

You shouldn't need that. The DBIC::Schema model will create all the
classes under the root namespace from the result source classes in the
DBIC schema.

However, I think the namespace in the book is AddressDB, not DBIC.

Regards,
Jonathan Rockway

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

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


archan2000 at yahoo

May 10, 2008, 10:14 PM

Post #8 of 11 (289 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

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?



--- On Sat, 5/10/08, Jonathan Rockway <jon[at]jrock.us> wrote:

> From: Jonathan Rockway <jon[at]jrock.us>
> Subject: Re: [Catalyst] session in DB example in Catalyst book
> To: "The elegant MVC web framework" <catalyst[at]lists.scsys.co.uk>
> Date: Saturday, May 10, 2008, 6:43 PM
> * On Sat, May 10 2008, Andreas Marienborg wrote:
> > On May 10, 2008, at 3:53 AM, Andrew wrote:
> >
> >
> > Using the Rockway's Catalyst book to help
> bring me up to speed on Catalyst
> > and I've got a problem that I can't figure
> out.
> >
> > On page 59, where it uses a database to store the
> session key, I've made
> > all the code changes, but when I start the server
> it gives me the following
> > error:
> >
> > "Couldn't find a model named
> DBIC::Session at /usr/local/share/perl/5.8.8/
> > Catalyst/Plugin/Session/Store/DBIC.pm line 143.
> > Compilation failed in require at
> script/addressbook_server.pl line 53."
> >
> >
> > You don't seem to have the Model you configured
> the session store to use. Do
> > you have the MyApp/Model/DBIC/Session.pm file?
>
> You shouldn't need that. The DBIC::Schema model will
> create all the
> classes under the root namespace from the result source
> classes in the
> DBIC schema.
>
> However, I think the namespace in the book is AddressDB,
> not DBIC.
>
> Regards,
> Jonathan Rockway
>
> --
> print just => another => perl => hacker => if
> $,=$"
>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo:
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/


____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

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


omega at palle

May 11, 2008, 12:04 AM

Post #9 of 11 (289 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

On May 11, 2008, at 7:14 AM, 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?
>
>
It is a config setting:

http://cpansearch.perl.org/~danieltwc/Catalyst-Plugin-Session-Store-DBIC-0.06/lib/Catalyst/Plugin/Session/Store/DBIC.pm#session_store_dbic_class

- andreas



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


jon at jrock

May 11, 2008, 12:07 AM

Post #10 of 11 (289 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

* 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.)

</digression>

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.

Regards,
Jonathan Rockway

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

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


jon at jrock

May 11, 2008, 12:13 AM

Post #11 of 11 (289 views)
Permalink
Re: session in DB example in Catalyst book [In reply to]

* On Sun, May 11 2008, Andreas Marienborg wrote:
> On May 11, 2008, at 7:14 AM, 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?
>>
>>
> It is a config setting:
>
> http://cpansearch.perl.org/~danieltwc/Catalyst-Plugin-Session-Store-DBIC-0.06/lib/Catalyst/Plugin/Session/Store/DBIC.pm#session_store_dbic_class
>
> - andreas

Actually, it's just a (documented) method:

=head2 session_store_dbic_class

Return the L<DBIx::Class> class name to be passed to C<< $c->model >>.
Defaults to C<DBIC::Session>.

=cut

sub session_store_dbic_class {
shift->config->{session}->{dbic_class} || 'DBIC::Session';
}

As I've mentioned in two other posts, I assume Andrew's problem is that
he didn't configure the plugin as per p.60 of the book. After reading
this method, I am even more sure that I'm right :)

Regards,
Jonathan Rockway

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

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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.