From 4980dad8a1bb31f27259acb638a77daee7e4b38f Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 1 Jun 2010 17:21:31 +0000 Subject: [PATCH] in the SIP server plugin, don't connect and start a transaction by default with every cstore handle. only connect/begin when necessary. also, making use of new CStoreEditor::init() call for setting up the editor environment when initial load was done before the IDL was available. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16544 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/SIP.pm | 22 ++++------------------ Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm | 12 +++++++----- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP.pm b/Open-ILS/src/perlmods/OpenILS/SIP.pm index 739c646e96..3d35dacafe 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP.pm @@ -78,34 +78,20 @@ sub to_bool { } sub editor { - return $editor - if $editor and $editor->{session} - and $editor->session->connected; return $editor = make_editor(); } -sub reset_editor { - $editor = undef; - return editor(); -} - sub config { return $config; } # Creates the global editor object +my $cstore_init = 1; # call init on first use sub make_editor { - require OpenILS::Utils::CStoreEditor; - my $e = OpenILS::Utils::CStoreEditor->new(xact => 1); - # gnarly cstore hack to re-gen autogen methods after IDL is loaded - if(!UNIVERSAL::can($e, 'search_actor_card')) { - syslog("LOG_WARNING", "OILS: Reloading CStoreEditor..."); - delete $INC{'OpenILS/Utils/CStoreEditor.pm'}; - require OpenILS::Utils::CStoreEditor; - $e = OpenILS::Utils::CStoreEditor->new(xact =>1); - } - return $e; + OpenILS::Utils::CStoreEditor::init() if $cstore_init; + $cstore_init = 0; + return OpenILS::Utils::CStoreEditor->new; } =head2 clean_text(scalar) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm index b1f9fc951d..9f84e650f9 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm @@ -509,17 +509,20 @@ sub unavail_holds { sub block { my ($self, $card_retained, $blocked_card_msg) = @_; + my $e = $self->{editor}; my $u = $self->{user}; - my $e = $self->{editor} = OpenILS::SIP->reset_editor(); syslog('LOG_INFO', "OILS: Blocking user %s", $u->card->barcode ); return $self if $u->card->active eq 'f'; + # connect and start a new transaction + $e->xact_begin; + $u->card->active('f'); if( ! $e->update_actor_card($u->card) ) { syslog('LOG_ERR', "OILS: Block card update failed: %s", $e->event->{textcode}); - $e->xact_rollback; + $e->rollback; # rollback + disconnect return $self; } @@ -532,15 +535,14 @@ sub block { if( ! $e->update_actor_user($u) ) { syslog('LOG_ERR', "OILS: Block: patron alert update failed: %s", $e->event->{textcode}); - $e->xact_rollback; + $e->rollback; # rollback + disconnect return $self; } # stay in synch $self->{user}->alert_message( $note ); - $e->commit; # commits and resets - $self->{editor} = OpenILS::SIP->reset_editor(); + $e->commit; # commits and disconnects return $self; } -- 2.11.0