From 034468b781e02f73439646862f1054a07957e402 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 9 Feb 2005 19:24:00 +0000 Subject: [PATCH] adding subrequest support git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@38 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/AppSession.pm | 18 ++++++++++++++++++ src/perlmods/OpenSRF/Application.pm | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index ff191fa..8aa275f 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -819,6 +819,24 @@ sub respond_complete { } +package OpenSRF::AppSubrequest; + +sub respond { + my $self = shift; + my $resp = shift; + push @{$$self{resp}}, $resp; +} + +sub new { + return bless({resp => []}, 'OpenSRF::AppSubrequest'); +} + +sub responses { @{$_[0]->{resp}} } + +sub status {} + + + 1; diff --git a/src/perlmods/OpenSRF/Application.pm b/src/perlmods/OpenSRF/Application.pm index 1adc67d..4648b6b 100644 --- a/src/perlmods/OpenSRF/Application.pm +++ b/src/perlmods/OpenSRF/Application.pm @@ -213,7 +213,20 @@ sub method_lookup { sub run { my $self = shift; - $self->{code}->($self, @_); + my $req = shift; + + unless ( ref($req) and UNIVERSAL::isa($req, 'OpenSRF::AppRequest') ) { + unshift @_, $req; + $req = OpenSRF::AppSubrequest->new; + } + + my $resp = $self->{code}->($self, $req, @_); + + if ( ref($req) and UNIVERSAL::isa($req, 'OpenSRF::AppSubrequest') ) { + return $req->responses; + } + + return $resp; } 1; -- 2.11.0