Could anyone help me get my head around how I implement a common base 
class for, and subclasses of, autogenerated DBIx::Class classes?

Going with a simple example:


    Foo::User    Foo::Project       <<< My sub classes
       |             |
       |             |
    Foo::user    Foo::project       <<< sqlt generated DBIx::Class classes
        \           /
         \         /
          \       /
           \     /
            \   /
             \ /
         Foo::Base                   <<< Common functionality


1) Foo::Base would hold common functionality for sub classes.


2) A::B::user and A::B::project would probably be defined within Foo.pm as 
autogenerated by sqlt:

  sqlt --from DBI --to DBIx::Class::File --prefix Foo --dsn DBI:mysql:foo > 
Foo.pm


3) Foo::User, Foo::Project would be the concrete subclasses, both adding new 
methods, and overriding methods in Foo::user, Foo::project.


So in the main code:

  use Foo;

  my $schema = Foo->connect('DBI:mysql:myapp');

  my $rs = $schema->resultset('User');     # Should get me the resultset for 
Foo::User

  $rs->create ....
  $rs->search ....


Normally I'd have no problems setting this up, but DBIx::Class seem a little 
more complex in the way it handles inheritance and registers classes 
and I'm not sure of the correct way to do this - I've tried a few things and I 
end up with instances of Foo::user rather than Foo::User (same with project) 
so something's clearly wrong.

I'd be really grateful if someone can tell me if this is possible (or what I 
should be doing instead) and could post an outline of how I would 
achieve this correctly using DBIx::Class. I'm happy to turn this thread
(if I get some replies) into a FAQ for the docs if that's of any use.

Many thanks,
Rich
-- 
Rich
[EMAIL PROTECTED]

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to