[OpenSRF-GIT] OpenSRF branch rel_2_2 updated. osrf_rel_2_2_0-4-gd081052

Evergreen Git git at git.evergreen-ils.org
Tue Aug 6 14:17:28 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, rel_2_2 has been updated
       via  d081052e872468d228d55c8fc4eb6cffa527da3b (commit)
       via  811caee573b71ea3ac59c48f83d9ca29accad2f0 (commit)
      from  0a19073843476c02a168af1c00d6ccc5e0c03a14 (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 d081052e872468d228d55c8fc4eb6cffa527da3b
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 811caee573b71ea3ac59c48f83d9ca29accad2f0
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