[Dbix-class] Moose wrapper around DBIC

John Napiorkowski jjn1056 at yahoo.com
Sun Apr 11 15:03:47 GMT 2010





----- Original Message ----
> From: Moritz Onken <onken at houseofdesign.de>
> To: DBIx::Class user and developer list <dbix-class at lists.scsys.co.uk>
> Sent: Wed, April 7, 2010 12:33:25 PM
> Subject: Re: [Dbix-class] Moose wrapper around DBIC
> 
> Hi,

you can find the sources at http://github.com/monken/p5-moosex-dbic. 
> Also checkout http://github.com/monken/p5-moosex-attribute-deflator since this 
> is required. 
This is far from usable. But have a look at the tests. I guess 
> they tell you what is working already.

cheers,
mo

You may wish to take a look at: http://search.cpan.org/~groditi/MooseX-TypeMap-0.002000/lib/MooseX/TypeMap.pm
 if you are trying to map sql ddl types. 

--john

Am 05.04.2010 
> um 19:45 schrieb Oleg Kostyuk:

> Very interesting.
> Where it's 
> possible to look at sources?
> 
> 2010/3/24 Moritz Onken <
> ymailto="mailto:onken at houseofdesign.de" 
> href="mailto:onken at houseofdesign.de">onken at houseofdesign.de>:
>> 
> Hi,
>> 
>> the latest discussion about using Moose and DBIC 
> got me thinking and I
>> started a little proof of concept 
> project.
>> It's called MooseX:DBIC. It contains a MooseX::DBIC::Schema 
> class which is
>> a subclass of DBIx::Class::Schema.
>> 
> 
>> The idea is to have a layer which takes Moose classes and generates 
> a dbic
>> schema, including column information and 
> relationships.
>> 
>> package User;
>> use 
> Moose;
>> has [qw(first last email password)] => ( is => 'rw', 
> isa => 'Str' );
>> 
>> sub talk { 'Hello' }
>> 
> 
>> and load this class in the schema:
>> 
>> package 
> MySchema;
>> use Moose;
>> extends 
> 'MooseX::DBIC::Schema';
>> 
> __PACKAGE__->load_classes('User');
>> 
>> This will create 
> the following classes:
>> 
>> MySchema::DBIC::User (which isa 
> DBIx::Class ResultSource class)
>> and
>> MySchema::User 
> (which isa "User" and does MooseX::DBIC::Result)
>> 
>> 
> inflate_result in MySchema::DBIC::User is extended to return a
>> 
> MySchema::User object instead of MySchema::DBIC::User. And 
> MySchema::User
>> has an attribute "dbic_result" which is set to the 
> dbic result row object.
>> 
>> MySchema::User inherits from 
> "User" and can be extended by a custom role to
>> change column_info 
> and more dbic related stuff.
>> MooseX::DBIC::Result adds proxy methods 
> to MySchema::User (i.e.
>> create/update/delete) which update the dbic 
> result object.
>> 
>> Example:
>> 
>> my 
> $user = $schema->resultset('User')->create({ first => 'foo' 
> });
>> # $user isa User, does MooseX::DBIC::Result
>> 
> $user->talk; # Hello
>> 
>> It works well so far, but 
> obviously a lot of things are still missing. One
>> nice feature I 
> implemented is subclassing. Imagine a class Admin which
>> extends User 
> and has some additional attributes. MooseX::DBIC::Schema will
>> create 
> two tables and the relationship admin has_one user.
>> 
>> I 
> just wanted to collect some opinions about this idea. If someone comes 
> up
>> with a good argument why this is retarded, please tell so I can 
> stop
>> wasting my time on this.
>> 
>> 
> cheers,
>> mo
>> 
>> 
> _______________________________________________
>> 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/dbix-class@lists.scsys.co.uk
>> 
> 
> 
> 
> 
> -- 
> Sincerely yours,
> Oleg 
> Kostyuk (CUB-UANIC)
> 
> 
> _______________________________________________
> List: 
> href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" 
> target=_blank 
> >http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: 
> irc.perl.org#dbix-class
> SVN: 
> href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target=_blank 
> >http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable 
> Archive: 
> target=_blank 
> >http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


_______________________________________________
List: 
> 
> target=_blank 
> >http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: 
> irc.perl.org#dbix-class
SVN: 
> href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target=_blank 
> >http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: 
> 
> target=_blank 
> >http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


      



More information about the DBIx-Class mailing list