You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thomas Klausner <do...@zsi.at> on 2000/11/12 00:02:40 UTC
Passing data structures between Stacked Handlers
Hi!
Is there a module that can do "Stacked Handler Pipelining", but
doesn't pass around tied filehandles but data structures ?
If there isn't, could it be implemented by dumping the data
structure to $r->notes (with Data::Dumper) and have it eval'ed back
by the next handler?
--
D_OMM http://domm.zsi.at
O_xyderkes
M_echanen NEU (naja): Wohnungs-Historie
M_asteuei http://domm.zsi.at/curvit/wohnen.html
Re: Passing data structures between Stacked Handlers
Posted by sp...@vancouver.yi.org.
On Sun, 12 Nov 2000, Dave Kaufman wrote:
> > Is there a module that can do "Stacked Handler Pipelining", but
> > doesn't pass around tied filehandles but data structures ?
Can't you allocate some generic namespace, or better yet, create your own
package called config and in that export functions get_config set_config
They will get/set a package wide variable. Then you make new,DESTROY, and
what other functions you need. Then you create/set object in the Init
module and the way you go, call get_config in each of the stacked modules
and insert data into it, so it will be passed along. Simple alternative,
you can store a hash in package wide namespace of the first package, and
access that via hashref, which is more convinient or Package::hashname
notation.
Thats how I did it.
> > If there isn't, could it be implemented by dumping the data
> > structure to $r->notes (with Data::Dumper) and have it eval'ed back
> > by the next handler?
God NO! Have you read of overhead incurring on eval? Might as well go back
to the days of PerlCGI,<choke, choke>
Hope that helped.
Pavel
Re: Passing data structures between Stacked Handlers
Posted by Dave Kaufman <dk...@nac.net>.
"Thomas Klausner" <do...@zsi.at> wrote:
> Is there a module that can do "Stacked Handler Pipelining", but
> doesn't pass around tied filehandles but data structures ?
Andreas König's Apache::HeavyCGI is a nice alternative approach to the use of stacked handlers.
> If there isn't, could it be implemented by dumping the data
> structure to $r->notes (with Data::Dumper) and have it eval'ed back
> by the next handler?
I just started playing around with HeavyCGI, but it uses the "Singleton" approach: one master handler "dispatches" each request to to all the modules that are needed, first allowing each a shot at processing headers (last-mod times, conditional tests, early errors, etc), then for content, and finally for cleanup, fixup, etc. this lets them all play together without the strict stacking and inefficient error-handling of stacked hadlers.
http://search.cpan.org/search?dist=Apache-HeavyCGI
-dave
Re: Passing data structures between Stacked Handlers
Posted by Thomas Klausner <do...@zsi.at>.
Hi!
> If you use $r->pnotes, you can just put a reference to an arbitrary data
> structure into it and it will still be there in the next handler. No
> need to serialize it with Data::Dumper. Better than using a normal
> global because it gets automatically cleaned up after the request.
Thanks for the info.
Ken Williams <ke...@forum.swarthmore.edu> also told me that
$r->pnotes wasn't included in the Eagle Book because it (pnotes,
not the book) wasn't implemented then. The old problem with
books.
--
D_OMM http://domm.zsi.at
O_xyderkes
M_echanen NEU (naja): Wohnungs-Historie
M_asteuei http://domm.zsi.at/curvit/wohnen.html
Re: Passing data structures between Stacked Handlers
Posted by Perrin Harkins <pe...@primenet.com>.
Thomas Klausner wrote:
> If there isn't, could it be implemented by dumping the data
> structure to $r->notes (with Data::Dumper) and have it eval'ed back
> by the next handler?
If you use $r->pnotes, you can just put a reference to an arbitrary data
structure into it and it will still be there in the next handler. No
need to serialize it with Data::Dumper. Better than using a normal
global because it gets automatically cleaned up after the request.
- Perrin