[Catalyst] Re: Reaction objects and DWIM for default => sub {...}

Guillermo Roditi groditi at gmail.com
Thu Jan 25 00:07:38 GMT 2007


Matt,

I added a sub BUILD { ... } to my schema files (Tablename.pm) and as i
suspected the BUILD action is never happening.. any clues? I also added a
new() action which throws a warning before calling it's next::method and i
came accross some interesting results... the code i added is below.

here's what I did and what the output was:
1. hit the base page
2. hit the create page
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
3. add an item from the M2M rel to the soon-to-be new object
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
4. Hit on the OK Button
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
new at /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line
1263
5. Hit Edit Page
6. Successfully edit item
7. Delete item

Why is new happening so many times? and why isn't BUILD ever happening? I am
assuming one new call is from cretaing the result set object and the other
one ends up proxying to new_result? The main issue though, is the Moose
'new' ever being called?


use Carp 'carp';

sub new{
    my ($type, @args) =3D @_;
    my $class =3D ref $type || $type;

    carp "new";
    my $self =3D $class->next::method(@args);
    return $self;
}

sub BUILD {
    my $self =3D shift;
    carp "BUILD";
}

upon using the CRUD create, edit



On 1/24/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
>
>
> On 24 Jan 2007, at 00:29, Guillermo Roditi wrote:
>
> > I even tried using this:
> > ...
> > has created_d  =3D> (is =3D> 'rw', required =3D> 1, isa =3D> 'DateTime',
> >                    default =3D> sub{ exit 0; } )
> >
> > ...
> >
> > and nothing happened. why is the default case not happening? is
> > this related to set_or_lazy_build? It seems like it could be
> > incredibly useful functionality for ActionReflector to support.
>
> Not entirely sure why it doesn't already copy that across; patches
> welcome.
> --
> Matt S Trout, Technical Director, Shadowcat Systems Ltd.
> Offering custom development, consultancy and support contracts for
> Catalyst,
> DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for
> details.
> + Help us build a better perl ORM: http://dbix-
> class.shadowcatsystems.co.uk/ +
>
>
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070124/b5a88=
87b/attachment-0001.htm


More information about the Catalyst mailing list