From: Bill Erickson Date: Thu, 23 May 2013 19:20:14 +0000 (-0400) Subject: Default per-request TPAC locale X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=859d49c348c3336789c2886e664fe6b0cf1a7bb7;p=evergreen%2Fequinox.git Default per-request TPAC locale Set the OpenSRF default client locale for each TPAC request to ensure all outbound OpenSRF calls use the requested locale. When done, reset the locale to the OpenSRF default. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index e5d5bb280a..57cb02b4dd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -8,6 +8,7 @@ use Encode; use Apache2::Const -compile => qw(OK DECLINED HTTP_INTERNAL_SERVER_ERROR); use Apache2::Log; use OpenSRF::EX qw(:try); +use OpenSRF::AppSession; use OpenILS::Utils::CStoreEditor q/:funcs/; use List::MoreUtils qw/uniq/; @@ -20,6 +21,18 @@ my %registered_locales; sub handler { my $r = shift; + my $stat = handler_guts($r); + + # other opensrf clients share this apache process, + # so it's critical to reset the locale after each + # response is handled, lest the other clients + # adopt our temporary, global locale value. + OpenSRF::AppSession->reset_locale; + return $stat; +} + +sub handler_guts { + my $r = shift; my $ctx = load_context($r); my $base = $ctx->{base_path}; @@ -173,7 +186,7 @@ sub load_context { parse_accept_lang($r->headers_in->get('Accept-Language')); # set the editor default locale for each page load - $OpenILS::Utils::CStoreEditor::default_locale = parse_eg_locale($ctx->{locale}); + OpenSRF::AppSession->default_locale(parse_eg_locale($ctx->{locale})); my $mprefix = $ctx->{media_prefix}; if($mprefix and $mprefix !~ /^http/ and $mprefix !~ /^\//) {