John Siracusa wrote: > On 3/26/07, Jeff Chimene <[EMAIL PROTECTED]> wrote: > >> make_classes(); >> >> sub make_classes >> { >> use base qw(Rose::DB Rose::DB::Object::Loader); >> > > You do not need to inherit from Rose::DB::Object::Loader. Loader is a > standalone class that can do work for you. It's not part of any > inheritance hierarchy in RDBO and should only be subclassed if you are > making a custom variant of the Loader. > > For your inspectDB Rose::DB-derived class, you should probably put the > "use base" bit near the top for clarity: > > package inspectDB; > > use strict; > > use base 'Rose::DB'; > > __PACKAGE__->register_db > ( > domain => 'development', > driver => 'mysql', > database => 'inspect_dev', > host => 'localhost', > username => 'xxx', > password => 'xxx', > ); > > __PACKAGE__->default_domain('development'); > > 1; >
I'm sure all this will be clearer when I look back on it a year from now. I just realized that you're saying "create a file named inspectDB.pm and put the above into it". This is probably trivial to those who use perl with packages syntax as a matter of course. Catalyst is the first time I've had to become acquainted with the concept of writing perl using the packages syntax. > That's it, the end of that file. If you plan to generate modules > using the Loader, you should do so from a separate script, not from > within your Rose::DB-derived class. Example: > > #!/usr/bin/perl > > use inspectDB; # your Rose::DB-derived class > use Rose::DB::Object::Loader; # the loader > > my $loader = > Rose::DB::Object::Loader->new( > db => inspectDB->new, > class_prefix => 'inspectDB::'); > > $loader->make_modules(module_dir => '/some/path/whatever'); > > The loader will raise an exception if something goes wrong, so there's > no need to catch the return value and check it. > Done. It works. >> 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"; >> > > Why is this calling script doing "use base ..." anything? Wouldn't > you just do this in a script? > > use inspectDB::Access::Manager; > > print inspectDB::Access::Manager->get_access_count(),"\n"; > Sadly, I posted an earlier variant of the file. I followed up with the current version. I'll live with the error for now. I'm sure I'll figure it out as I learn to use Catalyst and Rose. 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