[Dbix-class] Integration with Moose (DBIx-enabled Moose objects)?

Matt S Trout dbix-class at trout.me.uk
Mon Aug 25 20:01:46 BST 2008


On Sat, Aug 23, 2008 at 02:22:06PM +1000, Alex Peters wrote:
> Hi,
> 
> I'm starting a new project using Moose[1] and am wondering how
> best to handle persistent storage of these Moose objects.
> 
> If I weren't using Moose, DBIx::Class would be the obvious
> answer here.  However, in a way Moose and DBIx::Class seem to
> overlap in terms of the functionality that they provide (auto-
> generated accessors/mutators, etc.).
> 
> There seems to be very little information on the internet about
> using the two together, and I've scanned this year's posts to
> this mailing list for any references to Moose and found almost
> nothing[2] on this matter.

That's probably because the Moose community operates primarily by IRC,
even more so than the DBIC one - it's been discussed at some lenght on
both #moose and #dbix-class on irc.perl.org
 
> So: has anyone here written Moose classes that feature DBIx::
> Class functionality?  What approaches have been tried and how
> do they rank in usability and maintainability?

I just double-declare. Nothing really minds. See:

http://code2.0beta.co.uk/reaction/svn/Reaction/0.001/trunk/t/lib/RTest/TestDB/Foo.pm

which is what we're doing for Reaction apps as a stopgap until 0.09.

Equally, though, there's absolutely no reason you can't just use plain DBIC
objects and then apply method modifiers, roles etc. via Moose - the two
projects share quite a few committers in common so everything tends to
work just fine, and if it doesn't it gets fixed pretty quickly.

> Perhaps there's a (very well hidden) Moose plugin that makes
> the whole process trivial?

There's an svn-only MooseX::DBIC but (a) I don't like the API very much
(b) we're planning to port DBIC itself to Moose for 0.09 anyway.
 
> I'm not even sure if this is the right place to ask.  I'm kinda
> surprised that it hasn't really been asked yet--like the answer
> should be blatantly obvious, but I've stared at the problem for
> too long.

I hope the above clears things up a bit.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list