On Thu, Apr 11, 2013 at 11:28 AM, Peter Rabbitson <rabbit+d...@rabbit.us> wrote:
> On Thu, Apr 11, 2013 at 10:58:50AM -0400, shawn wilson wrote:
>> Since txn_* is a part of the schema, how do I have a resultset method
>> always run within one transaction without passing $schema (which just
>> seems kludgy)? Since I can't find anything on google about doing this,
>> I'm guessing it's a bad idea or there's some obviousness I'm missing?
>
> First
>
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#result_source
>
> And then
>
> http://search.cpan.org/~ribasushi/DBIx-Class-0.08210/lib/DBIx/Class/ResultSource.pm#schema
>

I don't understand. I've got this resultset class:

package DB::Schema::ResultSet::Page;

use strict;
use warnings;

use base 'DBIx::Class::ResultSet';

sub insert_page_array_ref
{
  my ($self, $pages) = @_;

  foreach my $page (@$pages)
  {
        next unless $page =~
m|^https?://(?:[\w]+\.)(?:\.?[\w]{2,})+(:[0-9]+)?(?:/[^/]+)+$|;
    $self->create({
      url   => $page,
      stamp => time,
    });
  }
}

1;

How do I wrap that in say a $schema->txn_do(sub{ ... }); ?

_______________________________________________
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

Reply via email to