[open-ils-commits] r17924 - in branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application: . Trigger (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Sep 23 11:46:29 EDT 2010
Author: miker
Date: 2010-09-23 11:46:26 -0400 (Thu, 23 Sep 2010)
New Revision: 17924
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
Log:
Merging r17905 and r17914 from trunk: A/T transaction semantics fixes
r17905: Use a transaction to avoid talking to a replicated db when building A/T data structures
r17914: In EventGroup.pm, fetch updated event back from the R/W db before comitting
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-09-23 15:40:48 UTC (rev 17923)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2010-09-23 15:46:26 UTC (rev 17924)
@@ -45,6 +45,10 @@
return $self if (!$self->id);
+ if ($self->standalone) {
+ $self->editor->xact_begin || return undef;
+ }
+
$self->event(
$self->editor->retrieve_action_trigger_event([
$self->id, {
@@ -57,6 +61,10 @@
])
);
+ if ($self->standalone) {
+ $self->editor->xact_rollback || return undef;
+ }
+
$self->user_data(OpenSRF::Utils::JSON->JSON2perl( $self->event->user_data ))
if (defined( $self->event->user_data ));
@@ -91,8 +99,16 @@
$meth =~ s/Fieldmapper:://;
$meth =~ s/::/_/;
+ if ($self->standalone) {
+ $self->editor->xact_begin || return undef;
+ }
+
$self->target( $self->editor->$meth( $self->event->target ) );
+ if ($self->standalone) {
+ $self->editor->xact_rollback || return undef;
+ }
+
return $self;
}
@@ -463,7 +479,7 @@
my $ed = grep( /open-ils.cstore/, @{$fclass->Controller} ) ?
$self->editor :
- new_rstore_editor();
+ new_rstore_editor(($self->standalone ? () : (xact=>1)));
my $obj = $context->$step();
@@ -473,11 +489,21 @@
);
if (!ref $obj) {
+
+ if ($self->standalone) {
+ $ed->xact_begin || return undef;
+ }
+
$obj = $ed->$meth(
($multi) ?
{ $ffield => $context->$lfield() } :
$context->$lfield()
);
+
+ if ($self->standalone) {
+ $ed->xact_rollback || return undef;
+ }
+
}
if (@$path) {
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2010-09-23 15:40:48 UTC (rev 17923)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2010-09-23 15:46:26 UTC (rev 17924)
@@ -212,11 +212,11 @@
if (scalar(@oks) < scalar(@{ $self->ids })) {
$self->editor->xact_rollback;
return undef;
- } else {
- $ok = $self->editor->xact_commit;
- }
+ }
my $updated = $self->editor->retrieve_action_trigger_event($last_updated);
+ $ok = $self->editor->xact_commit;
+
if ($ok) {
for my $event ( @{ $self->events } ) {
my $e = $event->event;
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2010-09-23 15:40:48 UTC (rev 17923)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2010-09-23 15:46:26 UTC (rev 17924)
@@ -57,13 +57,13 @@
# returns the calculated copy price
get_copy_price => sub {
my $copy_id = shift;
- return $U->get_copy_price(new_editor(), $copy_id);
+ return $U->get_copy_price(new_editor(xact=>1), $copy_id);
},
# given a copy, returns the title and author in a hash
get_copy_bib_basics => sub {
my $copy_id = shift;
- my $copy = new_editor()->retrieve_asset_copy([
+ my $copy = new_editor(xact=>1)->retrieve_asset_copy([
$copy_id,
{
flesh => 2,
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-09-23 15:40:48 UTC (rev 17923)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm 2010-09-23 15:46:26 UTC (rev 17924)
@@ -328,7 +328,7 @@
for (grep { $_ ne '-and' } keys %{$$filter{event}});
}
- my $e = new_editor();
+ my $e = new_editor(xact=>1);
my $events = $e->json_query($query);
@@ -595,8 +595,6 @@
my $client = shift;
my $granularity = shift;
- my $editor = new_editor();
-
my $query = [{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] }, 'join' => 'atevdef' }];
if (defined $granularity) {
@@ -605,7 +603,7 @@
$query->[0]->{'+atevdef'} = {granularity => undef};
}
- return $editor->search_action_trigger_event(
+ return new_editor(xact=>1)->search_action_trigger_event(
$query, { idlist=> 1, timeout => 7200, substream => 1 }
);
}
More information about the open-ils-commits
mailing list