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;

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.

> 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";

-John

-------------------------------------------------------------------------
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

Reply via email to