From d6067b6fe02a994926a490c3e4326de74a2e12b0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 17 Aug 2012 10:08:16 -0400 Subject: [PATCH] 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 --- .../src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) 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()!"; -- 1.7.2.5