From: Bill Erickson Date: Fri, 17 Aug 2012 14:08:16 +0000 (-0400) Subject: CStoreEditor default session locale X-Git-Url: http://git.equinoxoli.org/?p=transitory.git;a=commitdiff_plain;h=d6067b6fe02a994926a490c3e4326de74a2e12b0 CStoreEditor default session locale Adds a new package-level variable: $OpenILS::Utils::CStoreEditor::default_locale If set, this value is used as the session_locale for new opensrf client sessions. If unset, the session_locale remains untouched by CStoreEditor. Signed-off-by: Bill Erickson Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm index d41e435..51854e3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm @@ -13,6 +13,10 @@ my %PERMS; my $cache; my %xact_ed_cache; +# if set, we will use this locale for all new sessions +# if unset, we rely on the existing opensrf locale propagation +our $default_locale; + our $always_xact = 0; our $_loaded = 1; @@ -207,8 +211,17 @@ sub session { my( $self, $session ) = @_; $self->{session} = $session if $session; + # sessions can stick around longer than a single request/transaction. + # kill it if our default locale was altered since the last request + # and it does not match the locale of the existing session. + delete $self->{session} if + $default_locale and + $self->{session} and + $self->{session}->session_locale ne $default_locale; + if(!$self->{session}) { $self->{session} = OpenSRF::AppSession->create($self->app); + $self->{session}->session_locale($default_locale) if $default_locale; if( ! $self->{session} ) { my $str = "Error creating cstore session with OpenSRF::AppSession->create()!";