[Catalyst-commits] r12362 - trunk/examples/CatalystAdvent/root/2009/pen

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Mon Dec 14 14:09:14 GMT 2009


Author: caelum
Date: 2009-12-14 14:09:14 +0000 (Mon, 14 Dec 2009)
New Revision: 12362

Modified:
   trunk/examples/CatalystAdvent/root/2009/pen/dbic-txn.pod
Log:
minor changes

Modified: trunk/examples/CatalystAdvent/root/2009/pen/dbic-txn.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2009/pen/dbic-txn.pod	2009-12-14 13:24:19 UTC (rev 12361)
+++ trunk/examples/CatalystAdvent/root/2009/pen/dbic-txn.pod	2009-12-14 14:09:14 UTC (rev 12362)
@@ -63,12 +63,20 @@
 entries are guaranteed to be consistent, and we are using a more natural
 control flow.
 
-Any exceptions from C<txn_do> are rethrown, and ideally you'd clean them up in
-your C<end> handler, by getting them from C<< $c->error >>, or using something
-like L<Catalyst::Action::RenderView::ErrorHandler>. But in some cases you may
-want to wrap it in an eval (or one of L<Try::Catch>, L<Try::Tiny>) to detach in
-order to short-circuit a chain for example.
+Any exceptions from C<txn_do> are rethrown and a C<ROLLBACK> is issued, leaving
+the database untouched by the enclosed code.
 
+Exceptions can be cleaned up in your C<end> handler, by getting them from C<<
+$c->error >>, or using something like
+L<Catalyst::Action::RenderView::ErrorHandler>. But in some cases you may want
+to wrap them in an eval (or one of L<Try::Catch>, L<Try::Tiny>) to detach in
+order to, for example, short-circuit a chain.
+
+It is also recommended to factor out database code into the relevant
+L<DBIx::Class::ResultSet> methods. ResultSet classes go into e.g. the
+C<lib/MyApp/Schema/ResultSet> directory, next to your C<Result> directory and
+inherit from C<DBIx::Class::ResultSet>.
+
 =head2 Nested Transactions
 
 Many databases support a feature called 'savepoints', which are nested
@@ -112,6 +120,11 @@
 will not be added to any tables in the database, if they all fail then nothing
 will be added to the database.
 
+=head2 Transactions, a good idea!
+
+As you can see, database transactions and C<txn_do> can make your code safer
+and simpler.
+
 =head1 AUTHOR
 
 Caelum: Rafael Kitover <rkitover at cpan.org>




More information about the Catalyst-commits mailing list