[OpenSRF-GIT] OpenSRF branch master updated. b6cf3eb912fa501a23f4a3f5664f1a12228e731b

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, master has been updated
       via  b6cf3eb912fa501a23f4a3f5664f1a12228e731b (commit)
       via  e1581d4248a6fd42f6ebee233387777f63e25022 (commit)
      from  69cbe8000a5123aab33fcb2441c1e136506964a0 (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 b6cf3eb912fa501a23f4a3f5664f1a12228e731b
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 e1581d4248a6fd42f6ebee233387777f63e25022
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