Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

trying out Maypole: Class::DBI::Loader calling set_db?

by hossman (Prior)
on Jan 20, 2005 at 08:38 UTC ( [id://423621]=perlquestion: print w/replies, xml ) Need Help??

hossman has asked for the wisdom of the Perl Monks concerning the following question:

I've been looking at Maypole as a possible way to crank out simple tools based on an existing schema. After some initial installation headaches, I can't seem to get a trivial example working.

I'm starting with this perl.com article and the CGI::Maypole perldoc as a basis for my experiement. I created this simple "people" table...

mysql> use test; Database changed mysql> describe people; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | it | int(11) | | PRI | 0 | | | name | varchar(255) | YES | | NULL | | | bday | date | YES | | NULL | | +-------+--------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)

...and then i setup this Maypole driver...

package IsfdbMaypole; use strict; use warnings; use lib qw(/home/hossman/.perllib/lib/perl5/site_perl); use base 'CGI::Maypole'; IsfdbMaypole->config->uri_base("http://XXXXXXXXXXX/~hossman/maypole\ /"); IsfdbMaypole->config->display_tables([qw[people]]); IsfdbMaypole->config->rows_per_page(10); IsfdbMaypole->config->user("hossman"); IsfdbMaypole->config->pass("ZZZZZZZZZZZZ"); IsfdbMaypole->setup("dbi:mysql:test"); 1;

...and this index.cgi in my public_html/maypole directory...

#!/usr/bin/perl use strict; use warnings; use lib qw(/home/hossman/.perllib/lib/perl5/site_perl); use IsfdbMaypole; IsfdbMaypole->run();

The problem I'm running into is this...

Can't locate object method "set_db" via package "IsfdbMaypole::People" + at /home/hossman/.perllib/lib/perl5/site_perl/5.8.5/Class/DBI/Loader +/Generic.pm line 173. Compilation failed in require at /home/hossman/public_html/maypole/ind +ex.cgi line 5. BEGIN failed--compilation aborted at /home/hossman/public_html/maypole +/index.cgi line 5.

what is the "set_db" method and why does Class::DBI::Loader::Generic think it needs to be called? Has anyone encountered this error before? Did I do something wrong?

Replies are listed 'Best First'.
Re: trying out Maypole: Class::DBI::Loader calling set_db?
by Corion (Patriarch) on Jan 20, 2005 at 08:47 UTC

    The set_db method comes from Class:DBI. In theory the MsfdbMaypole::People class should have been set up properly by Class::DBI::Loader, but that does not seem to be the case, as it doesn't seem to have properly inherited from Class::DBI...

    Does Class::DBI(::Loader) work stand-alone for you?

    use Class::DBI::Loader; my $loader = Class::DBI::Loader->new( dsn => "dbi:mysql:test", user => "root", password => "", namespace => "IsfdbMaypole", additional_classes => qw/Class::DBI::AbstractSearch/, relationships => 1 ); my $person = IsfdbMaypole::People->create({name => 'J. Doe'});

      Hmm, aparently not. That test case resulted in the same error. Thanx for the suggestion.

      Do you have any idea why this happens?

      (I'll try to dig into the docs of Class::DBI::Loader a little more after i get off work.)

Re: trying out Maypole: Class::DBI::Loader calling set_db?
by nite_man (Deacon) on Jan 20, 2005 at 09:14 UTC

    I think you've forgotten add Class::DBI::Loader::Relationship in your base Maypole package:

    package IsfdbMaypole; use strict; use warnings; use lib qw(/home/hossman/.perllib/lib/perl5/site_perl); use base 'CGI::Maypole'; ### use Class::DBI::Loader::Relationship; ### IsfdbMaypole->config->uri_base("http://XXXXXXXXXXX/~hossman/maypole\ /"); IsfdbMaypole->config->display_tables([qw[people]]); IsfdbMaypole->config->rows_per_page(10); IsfdbMaypole->config->user("hossman"); IsfdbMaypole->config->pass("ZZZZZZZZZZZZ"); IsfdbMaypole->setup("dbi:mysql:test"); 1;

    ---
    Michael Stepanov aka nite_man

    It's only my opinion and it doesn't have pretensions of absoluteness!

      Good eye. I didn't include it because the CGI::Maypole example didn't bother with it either. It was my understanding that since I was only dealing with a single table -- and had not configured any relationships -- it shouldn't be neccessary. I tried adding it back in which no change to the error.

      I think Corion has given me a good pointer to the source of the problem, now i just have to follow that pointer and see where it leads.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://423621]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found