[Catalyst-commits] r12167 - trunk/examples/CatalystAdvent/root/2009
alexn_org at dev.catalyst.perl.org
alexn_org at dev.catalyst.perl.org
Thu Dec 3 17:15:13 GMT 2009
Author: alexn_org
Date: 2009-12-03 17:15:12 +0000 (Thu, 03 Dec 2009)
New Revision: 12167
Modified:
trunk/examples/CatalystAdvent/root/2009/3.pod
Log:
replaced schema init with self->schema
Modified: trunk/examples/CatalystAdvent/root/2009/3.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2009/3.pod 2009-12-03 17:14:36 UTC (rev 12166)
+++ trunk/examples/CatalystAdvent/root/2009/3.pod 2009-12-03 17:15:12 UTC (rev 12167)
@@ -297,9 +297,7 @@
my $self = shift;
my $item = $self->item;
- my $schema = $item->result_source->schema;
-
- my $changes = sub {
+ $self->schema->txn_do(sub {
$orig->($self, @_);
my @tags = split /\s*,\s*/, $self->field('tags_str')->value;
@@ -307,9 +305,7 @@
$item->article_tags->delete;
$item->article_tags->create({ tag => { name => $_ } })
foreach (@tags);
- };
-
- $schema->txn_do($changes);
+ });
};
We have this flexibility, since HTML::FormHandler is based on
@@ -374,7 +370,7 @@
# .... <init here> ...
- my $changes = sub {
+ $self->schema->txn_do(sub {
$orig->($self, @_);
# .... < tags saving here > ....
@@ -382,9 +378,7 @@
# generates the summary and updates the $item
my $summary = generate_symmary($item->content);
$item->update({ summary => $summary }) if $summary;
- };
-
- $schema->txn_do($changes);
+ });
};
You may have noticed schema->txn_do. That's a transaction. If any of
More information about the Catalyst-commits
mailing list