From: erickson Date: Fri, 19 Jan 2007 16:07:16 +0000 (+0000) Subject: added some sanity checks for session/transaction management. added a substream reque... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=766b01941ed06084c270e758028623147098f798;p=Evergreen.git added some sanity checks for session/transaction management. added a substream request option to force request to run in streaming mode, good for really big requests git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@6790 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm index 29445843dc..35a360cd36 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm @@ -209,12 +209,14 @@ sub xact_rollback { sub rollback { my $self = shift; $self->xact_rollback if $self->{xact}; + delete $self->{xact}; $self->disconnect; } sub disconnect { my $self = shift; $self->session->disconnect if $self->{session}; + delete $self->{session}; } @@ -269,7 +271,20 @@ sub request { } try { - $val = $self->session->request($method, @params)->gather(1); + + my $req = $self->session->request($method, @params); + + if( $self->substream ) { + $self->log(D,"running in substream mode"); + $val = []; + while( my $resp = $req->recv ) { + push(@$val, $resp->content) if $resp->content; + } + } else { + $val = $req->gather(1); + } + + #$val = $self->session->request($method, @params)->gather(1); } catch Error with { $err = shift; @@ -280,6 +295,12 @@ sub request { return $val; } +sub substream { + my( $self, $bool ) = @_; + $self->{substream} = $bool if defined $bool; + return $self->{substream}; +} + # ----------------------------------------------------------------------------- # Sets / Returns the requstor object. This is set when checkauth succeeds. @@ -435,6 +456,8 @@ sub __arg_to_string { sub runmethod { my( $self, $action, $type, $arg, $options ) = @_; + $options ||= {}; + if( $action eq 'retrieve' ) { if(! defined($arg) ) { $self->log(W,"$action $type called with no ID..."); @@ -470,6 +493,8 @@ sub runmethod { $method =~ s/search/id_list/o if $options->{idlist}; + $method =~ s/\.atomic$//o if $self->substream($$options{substream}); + # remove any stale events $self->clear_event;