You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark McWiggins <ma...@IcanFixYourEmail.com> on 2005/04/09 23:35:40 UTC

Class::DBI + mod_perl? "Can't locate object method 'search' ...

Hi All,

"Plan to throw one away" (see *The Mythical Man-Month* by Brooks), 
indeed: I've just about finished a more-complex
than-I-thought web + database application and then too late thought 
"gosh, nice if there were something like Hibertnate
for Perl." A quick web search led me to Class::DBI, which looks like it 
will eliminate 75% of the code I just wrote, and
good riddance to it since I have to maintain the thing ongoing.

BUT ... I have a small example working as a standalone Perl script but 
can't get it going inside mod_perl. I have a startup.pl
script running successfully:

> use lib qw(/usr/local/apache2/perl);
> use Class::DBI;
> use Class::DBI::Pg;
> use inforce;
> 1;


And the 'inforce' module is just simply:

> #!/usr/bin/perl
>
> use strict;
> use base qw(Class::DBI::Pg);
>
> __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=etracclass', 'nobody', '');
> __PACKAGE__->set_up_table('inforce');
>
> 1;
>

But I can't get my Apache::ASP page to recognize it with any combination of

    use inforce;

with or without the other classes above in 'startup.pl'. I get
   
    Can't's locate object method "search" via package 'inforce' ...

Obviously this is something simple -- thanks in advance for any guidance 
whatsoever
on this.

-- 
Mark McWiggins
425-369-8286 (let ring)


Re: Class::DBI + mod_perl? "Can't locate object method 'search' ...

Posted by Michael Peters <mp...@plusthree.com>.
Mark McWiggins wrote:
> Hi All,
> 
> "Plan to throw one away" (see *The Mythical Man-Month* by Brooks), 
> indeed: I've just about finished a more-complex
> than-I-thought web + database application and then too late thought 
> "gosh, nice if there were something like Hibertnate
> for Perl." A quick web search led me to Class::DBI, which looks like it 
> will eliminate 75% of the code I just wrote, and
> good riddance to it since I have to maintain the thing ongoing.

It does reduce a lot of code, but as you've seen, it has it's own 
quirks... Maybe that's why we love it so much :)

> BUT ... I have a small example working as a standalone Perl script but 
> can't get it going inside mod_perl. I have a startup.pl
> script running successfully:

I don't know if it addresses the specific issue you are having, but 
there is a wiki page just for running C::D under mod_perl.

http://www.class-dbi.com/cgi-bin/wiki/index.cgi?UsingWithModPerl

If you aren't having some of these issues now, you soon will be, so at 
least I have lent a hand on your next problem :)

>> use lib qw(/usr/local/apache2/perl);
>> use Class::DBI;
>> use Class::DBI::Pg;
>> use inforce;
>> 1;
> 
> 
> 
> And the 'inforce' module is just simply:
> 
>> #!/usr/bin/perl
>>
>> use strict;
>> use base qw(Class::DBI::Pg);
>>
>> __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=etracclass', 'nobody', '');
>> __PACKAGE__->set_up_table('inforce');
>>
>> 1;
>>
> 
> But I can't get my Apache::ASP page to recognize it with any combination of
> 
>    use inforce;
> 
> with or without the other classes above in 'startup.pl'. I get
>      Can't's locate object method "search" via package 'inforce' ...
> 
> Obviously this is something simple -- thanks in advance for any guidance 
> whatsoever
> on this.

HTH a little.

-- 
Michael Peters
Developer
Plus Three, LP


Re: Class::DBI + mod_perl? "Can't locate object method 'search' ...

Posted by David J Radunz <da...@staff.netspace.net.au>.
On Sat, 2005-04-09 at 14:35 -0700, Mark McWiggins wrote:
> Hi All,
> 
> "Plan to throw one away" (see *The Mythical Man-Month* by Brooks), 
> indeed: I've just about finished a more-complex
> than-I-thought web + database application and then too late thought 
> "gosh, nice if there were something like Hibertnate
> for Perl." A quick web search led me to Class::DBI, which looks like it 
> will eliminate 75% of the code I just wrote, and
> good riddance to it since I have to maintain the thing ongoing.
> 
> BUT ... I have a small example working as a standalone Perl script but 
> can't get it going inside mod_perl. I have a startup.pl
> script running successfully:
> 
> > use lib qw(/usr/local/apache2/perl);
> > use Class::DBI;
> > use Class::DBI::Pg;
> > use inforce;
> > 1;
> 
> 
> And the 'inforce' module is just simply:
> 
> > #!/usr/bin/perl
> >
> > use strict;
> > use base qw(Class::DBI::Pg);
> >
> > __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=etracclass', 'nobody', '');
> > __PACKAGE__->set_up_table('inforce');
> >
> > 1;
> >
> 

why doesn't inforce have a package declaration?

i.e.  package inforce;

and you dont need #!/usr/bin/perl at the top for modules.

Also, why isnt 'inforce.pm' loading the Class DBI modules instead of the
startup.pl script..

We have Class::DBI working fine under mod_perl - I think its just your
implementation that needs refinement :)


> But I can't get my Apache::ASP page to recognize it with any combination of
> 
>     use inforce;
> 
> with or without the other classes above in 'startup.pl'. I get
>    
>     Can't's locate object method "search" via package 'inforce' ...
> 
> Obviously this is something simple -- thanks in advance for any guidance 
> whatsoever
> on this.
> 

This email and any files transmitted with it are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. Please notify the sender 
immediately by email if you have received this email by mistake and delete this email 
from your system. Please note that any views or opinions presented in this email are solely
 those of the author and do not necessarily represent those of the organisation. 
Finally, the recipient should check this email and any attachments for the presence of 
viruses. The organisation accepts no liability for any damage caused by any virus 
transmitted by this email.