John Siracusa wrote: > On 3/26/07, Jeff Chimene <[EMAIL PROTECTED]> wrote: > >> John Siracusa wrote: >> >>> On 3/23/07, Jeff Chimene <[EMAIL PROTECTED]> wrote: >>> >>>> How do I eliminate the following error message? >>>> $ perl ./fred.pl >>>> Subroutine init_db redefined at inspectDB/DB/Object/AutoBase1.pm line 7. >>>> >>> AutoBaseNNN.pm classes are the automatically generated RDBO base >>> classes created by the Loader. How is the inspectDB::Access class >>> being created? I suspect that's where your problem is, not in the >>> Manager. >>> >> That's also created w/ make_methods(). Here is the (truncated) source. >> >> package inspectDB::Access; >> use strict; >> use base qw(inspectDB::DB::Object::AutoBase1); >> __PACKAGE__->meta->setup( >> table => 'access', >> <snip> >> ); >> 1; >> >> I see a reference to AutoBase1 here as well. So, what's the proper way >> to reference the results of make_methods()? >> > > I think you mean make_modules(), not make_methods(), right? Yes. My apologies for the confusion. > Are you using the Loader to produce a bunch of .pm files, or are you using it > to create a bunch of classes in memory only? The former. > Either way, can you post a self-contained example including a simple db > schema I cannot post a "simple" schema. I can post the Access table.
CREATE TABLE `access` ( `id` int(4) NOT NULL auto_increment, `username` text , `password` text , `maiden` text , `sysop` tinyint(1) NOT NULL default '0' COMMENT 'True when subscriber has SYSOP role', `boss` tinyint(1) NOT NULL default '0' COMMENT 'True when subscriber has BOSS role', `status` tinyint(1) NOT NULL default '0' COMMENT 'Not used', `guest` tinyint(1) NOT NULL default '0' , `level` enum('Beginner','Intermediate','Expert') NOT NULL default 'Beginner' COMMENT 'Verbosity level in checksheet', `company_name` int(4) NOT NULL default '0' COMMENT 'FK reference to inspection_company.name', `inspector_name` int(4) NOT NULL default '0' COMMENT 'FK reference to inspector.name', `realtor_office` int(4) NOT NULL default '0' COMMENT 'FK reference to office.name when guest is True', `realtor_name` int(4) NOT NULL default '0' COMMENT 'FK reference to realtor.name when guest is True', PRIMARY KEY (`id`), KEY `inspector_name` (`inspector_name`), KEY `realtor_office` (`realtor_office`), KEY `realtor_name` (`realtor_name`), KEY `company_name` (`company_name`), CONSTRAINT `Access.Inspection_Company` FOREIGN KEY (`company_name`) REFERENCES `inspection_company` (`name`) ON DELETE CASCADE, CONSTRAINT `Access.Inspector` FOREIGN KEY (`inspector_name`) REFERENCES `inspector` (`name`) ON DELETE CASCADE, CONSTRAINT `Access.Name.Realtor_Name` FOREIGN KEY (`realtor_name`) REFERENCES `realtor` (`name`) ON DELETE CASCADE, CONSTRAINT `Access.Name.Realtor_Office` FOREIGN KEY (`realtor_office`) REFERENCES `office` (`name`) ON DELETE CASCADE Please see above for the RDBO package created for this table. > and then the Loader call Here is the make_modules() call. #!/usr/bin/perl -w package inspectDB; use strict; use warnings; __PACKAGE__->register_db( domain => 'development', driver => 'mysql', database => 'inspect_dev', host => 'localhost', username => 'xxx', password => 'xxx', ); __PACKAGE__->default_domain('development'); make_classes(); sub make_classes { use base qw(Rose::DB Rose::DB::Object::Loader); my $loader = Rose::DB::Object::Loader->new(db => __PACKAGE__->new , class_prefix => 'inspectDB::') || die Rose::DB->error; $loader->make_modules(module_dir => '.') || die Rose::DB->error; } > and any other code needed to trigger the "init_db redefined" error you > described earlier? > Given the following file (Access.pm) in the Access/ directory created by make_methods(): package inspectDB::Access::Manager; use base qw(Rose::DB::Object::Manager); use inspectDB::Access; sub object_class { 'inspectDB::Access' } __ PACKAGE__->make_manager_methods('access'); 1; and this caller: #!/usr/bin/perl -w use strict; use base 'Rose::DB::Object::Manager'; use inspectDB::Access; print inspectDB::Access::Manager->get_access_count(),"\n"; I think there's a parameter I have to set to tell it to not generate the use base setting. Either that or I add a "use base" to the "root" module? Cheers, jec ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object