[OpenSRF-GIT] OpenSRF branch master updated. 8a4ee2d74b0e8c2ca95b85328c687b8a074198f6
Evergreen Git
git at git.evergreen-ils.org
Tue Aug 6 14:15:56 EDT 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via 8a4ee2d74b0e8c2ca95b85328c687b8a074198f6 (commit)
via 8524849b01c1ab81a2b6d5799990d1dbfec22014 (commit)
from 135fa8cf5bdcf7a9cbdf75931734c86fd09489ef (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8a4ee2d74b0e8c2ca95b85328c687b8a074198f6
Author: Galen Charlton <gmc at esilibrary.com>
Date: Tue Aug 6 22:00:15 2013 +0000
LP#1188195: add tests for setting default client locale
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/t/02-AppSession.t b/src/perl/t/02-AppSession.t
index 1ac6673..01cce39 100644
--- a/src/perl/t/02-AppSession.t
+++ b/src/perl/t/02-AppSession.t
@@ -1,7 +1,14 @@
#!perl -T
-use Test::More tests => 1;
+use strict;
+use warnings;
+use Test::More tests => 3;
BEGIN {
use_ok( 'OpenSRF::AppSession' );
}
+
+my $locale = OpenSRF::AppSession->default_locale('fr-CA');
+is($locale, 'fr-CA', 'got back the default locale we set');
+$locale = OpenSRF::AppSession->reset_locale();
+is($locale, 'en-US', 'got back en-US after reset of default locale');
commit 8524849b01c1ab81a2b6d5799990d1dbfec22014
Author: Bill Erickson <berick at esilibrary.com>
Date: Thu May 23 15:17:12 2013 -0400
LP#1188195: Default per-process client locale (Perl)
Get/set the locale used by all new client sessions
for the current process. This is primarily useful
for clients that wish to make a series of opensrf
calls and don't wish to set the locale for each new
AppSession object.
The caller should reset the locale when done using
reset_locale(), as the locale will otherwise persist
for the current process until set/reset again.
This is not for SERVER processes, since they
adopt the locale of their respective callers.
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/lib/OpenSRF/AppSession.pm b/src/perl/lib/OpenSRF/AppSession.pm
index d19085f..8b99c00 100644
--- a/src/perl/lib/OpenSRF/AppSession.pm
+++ b/src/perl/lib/OpenSRF/AppSession.pm
@@ -24,6 +24,28 @@ my $logger = "OpenSRF::Utils::Logger";
my $_last_locale = 'en-US';
our $current_ingress = 'opensrf';
+# Get/set the locale used by all new client sessions
+# for the current process. This is primarily useful
+# for clients that wish to make a series of opensrf
+# calls and don't wish to set the locale for each new
+# AppSession object.
+#
+# The caller should reset the locale when done using
+# reset_locale(), as the locale will otherwise persist
+# for the current process until set/reset again.
+#
+# This is not for SERVER processes, since they
+# adopt the locale of their respective callers.
+sub default_locale {
+ my ($class, $locale) = @_;
+ $_last_locale = $locale if $locale;
+ return $_last_locale;
+}
+sub reset_locale {
+ my ($class) = @_;
+ return $_last_locale = 'en-US';
+}
+
sub ingress {
my ($class, $ingress) = @_;
$current_ingress = $ingress if $ingress;
-----------------------------------------------------------------------
Summary of changes:
src/perl/lib/OpenSRF/AppSession.pm | 22 ++++++++++++++++++++++
src/perl/t/02-AppSession.t | 9 ++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list