[OpenSRF-GIT] OpenSRF branch rel_2_4 updated. osrf_rel_2_4_1-5-g65ed54c

Evergreen Git git at git.evergreen-ils.org
Thu Feb 4 13:11:21 EST 2016


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_4 has been updated
       via  65ed54c4dc713919756644d3873f8fa7d851b427 (commit)
       via  675c7a693d9a5d4f228d7b7ca5fe3b3f7fd62214 (commit)
      from  b484a31c413a017c6b7409f3f101636f68c08c9a (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 65ed54c4dc713919756644d3873f8fa7d851b427
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Thu Feb 4 13:09:48 2016 -0500

    LP#1350457: add test case for perl2JSONObject change
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/src/perl/t/09-Utils-JSON.t b/src/perl/t/09-Utils-JSON.t
index ff5d580..431b896 100644
--- a/src/perl/t/09-Utils-JSON.t
+++ b/src/perl/t/09-Utils-JSON.t
@@ -29,14 +29,17 @@ is (OpenSRF::Utils::JSON->false, 0);
 # register_class_hint
 my $testmap =  { hints   => { osrfException =>
                               { hint => 'osrfException',
+                                strip => ['session'],
                                 name => 'OpenSRF::DomainObject::oilsException' }
                             },
                  classes => { 'OpenSRF::DomainObject::oilsException' =>
                               { hint => 'osrfException',
+                                strip => ['session'],
                                 name => 'OpenSRF::DomainObject::oilsException' }
                             }
                };
 OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfException',
+                                           strip => ['session'],
                                            name => 'OpenSRF::DomainObject::oilsException');
 is_deeply (\%OpenSRF::Utils::JSON::_class_map, $testmap);
 
@@ -99,7 +102,7 @@ is (UNIVERSAL::isa($coderef,'CODE'), 1);   # code doesn't stop me from doing it
 is_deeply (OpenSRF::Utils::JSON->perl2JSONObject($coderef),
            { __c => 'CODE', __p => undef }, "Passing in coderef");
 
-my $fakeobj = bless { foo => 'bar' }, 'OpenSRF::DomainObject::oilsException';
+my $fakeobj = bless { foo => 'bar', session => 'hidden session stuff' }, 'OpenSRF::DomainObject::oilsException';
 is (UNIVERSAL::isa($fakeobj,'HASH'), 1);
 my $jsonobj = OpenSRF::Utils::JSON->perl2JSONObject($fakeobj);
 is_deeply ($jsonobj, { __c => 'osrfException', __p => { foo => 'bar' } },

commit 675c7a693d9a5d4f228d7b7ca5fe3b3f7fd62214
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Jul 30 13:29:46 2014 -0400

    LP#1350457: Pass caller's session to subrequests called via method_lookup
    
    In the process of looking up a method for an internal subrequest, we lose
    session info. This is a problem when the subrequest makes a remote request,
    because then the subrequest can't look up the proper locale, among other
    things. The forthcoming branch passes the caller's session to the subrequest.
    
    This patch also teaches OpenSRF object registration how to strip certain
    object members -- in particular, the session -- so that introspection
    continues to work.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/src/perl/lib/OpenSRF/Application.pm b/src/perl/lib/OpenSRF/Application.pm
index 5ae98bf..023bb8d 100644
--- a/src/perl/lib/OpenSRF/Application.pm
+++ b/src/perl/lib/OpenSRF/Application.pm
@@ -171,6 +171,7 @@ sub handler {
 
 		if (ref $coderef) {
 			my @args = $app_msg->params;
+			$coderef->session( $session );
 			my $appreq = OpenSRF::AppRequest->new( $session );
 			$appreq->max_chunk_size( $coderef->max_chunk_size );
 			$appreq->max_chunk_count( $coderef->max_chunk_count );
@@ -436,7 +437,12 @@ sub register_method {
 		($args{object_hint} = $args{package}) =~ s/::/_/go;
 	}
 
-	OpenSRF::Utils::JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
+	OpenSRF::Utils::JSON->register_class_hint(
+		strip => ['session'],
+		name => $app,
+		hint => $args{object_hint},
+		type => "hash"
+	);
 
 	$_METHODS[$args{api_level}]{$args{api_name}} = bless \%args => $app;
 
@@ -558,6 +564,7 @@ sub method_lookup {
 		$meth = $self->method_lookup($method,$proto,1);
 	}
 
+	$meth->session($self->session) if $meth && ref($self); # Pass the caller's session
 	return $meth;
 }
 
@@ -571,9 +578,7 @@ sub run {
 	if ( !UNIVERSAL::isa($req, 'OpenSRF::AppRequest') ) {
 		$log->debug("Creating a SubRequest object", DEBUG);
 		unshift @params, $req;
-		$req = OpenSRF::AppSubrequest->new;
-		$req->session( $self->session ) if ($self->session);
-
+		$req = OpenSRF::AppSubrequest->new( session => $self->session );
 	} else {
 		$log->debug("This is a top level request", DEBUG);
 	}
diff --git a/src/perl/lib/OpenSRF/Utils/JSON.pm b/src/perl/lib/OpenSRF/Utils/JSON.pm
index 6411870..4efa3dc 100644
--- a/src/perl/lib/OpenSRF/Utils/JSON.pm
+++ b/src/perl/lib/OpenSRF/Utils/JSON.pm
@@ -212,7 +212,14 @@ sub perl2JSONObject {
 
     if(UNIVERSAL::isa($obj, 'HASH')) {
         $jsonobj = {};
-        $jsonobj->{$_} = $pkg->perl2JSONObject($obj->{$_}) for (keys %$obj);
+        for my $k (keys %$obj) {
+            next if (
+                $ref ne 'HASH'
+                and exists $_class_map{classes}{$ref}{strip}
+                and grep { $k eq $_ } @{$_class_map{classes}{$ref}{strip}}
+            );
+            $jsonobj->{$k} = $pkg->perl2JSONObject($obj->{$k});
+        }
     } elsif(UNIVERSAL::isa($obj, 'ARRAY')) {
         $jsonobj = [];
         $jsonobj->[$_] = $pkg->perl2JSONObject($obj->[$_]) for(0..scalar(@$obj) - 1);

-----------------------------------------------------------------------

Summary of changes:
 src/perl/lib/OpenSRF/Application.pm |   13 +++++++++----
 src/perl/lib/OpenSRF/Utils/JSON.pm  |    9 ++++++++-
 src/perl/t/09-Utils-JSON.t          |    5 ++++-
 3 files changed, 21 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list