>
>
>
> Are most developers following the double declaration path I started with or
> are their better ways/other modules that would make this work better? Is it
> best to stick with double declaration until DBIC 0.9 comes out with full
> Moose integration?
>
>
In my neck of the woods, for large applications, we're using the DataMapper
pattern (separation of business model and database layer), which translates
into having a model layer like yours:

Model::User->create('bob');


Which in turn wraps, into a single transaction if possible, calls such as:

$schema->resultset('User')->create({ username=>'bob', password_reset=>1 );
$schema->resultset('UsersInGroup')->create( ... );
$ldap->create_user( ... );
$email->notify_admin( "user $user created" );
$email->notify_user("your password is..." );

I don't think you need use_moose=>1 if you're going towards this pattern. I
recommend taking a look into  MooseX::Types::DBIx::Class, which can be
combined with delegation ("handles") and method modifiers ("around") that
help you simplify method calls:

has 'row' => ( is=>'rw', isa=>Row, handles=>[qw/insert create delete/] );
has 'rs' => (is=>'rw', isa=>ResultSet, handles=>[qw/search find/] );


In the beginning it feels like you're duplicating code a lot, ie. when the
Model::User->create_user method only has a single line
"$schema->resultset('User')->create(...)" in it. But then, as your model
complexity grows, you'll be glad you have DBIC  for data and the Model, with
unlimited Moose powers, for everything else.

OTOH, for a simpler model (ie. the MojoMojo wiki) keeping everything in DBIC
is perfectly fine and may simplify your app enormously. Although I think
conceptually Moose and DBIC don't play along well in the same Result
class: they're each a OO system on their own despite "patches" such as
use_moose=>1, DBIx::Class::MooseColumns and moritz's cool experimental
MooseX::DBIC. In my experience, inheritance and roles work ok, but new(),
create() and accessor incoherencies are confusing enough to make me not want
a moose in my dbic tea.

Eden's comments in this thread are it:
http://dbix-class.35028.n2.nabble.com/minimalistic-Moose-DBIC-glue-module-td5100128.html

-rodrigo
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to