[Catalyst] report on trunk version of Plugin::SubRequest
John Napiorkowski
jjn1056 at yahoo.com
Sat Sep 30 01:22:20 CEST 2006
Hi,
I've been playing this the trunk version of the
subrequest plugin since I'm looking for a better
solution to my portal-like framework I've created on
this application. I find the CPAN subrequest doesn't
properly isolate itself and I get a lot of variable
collision. Right now I'm just doing an LWP request
for each page section. It works but generates a lot
of web traffic and just seems a bit heavy handed.
I know that there was some call for comments on the
trunk subrequest so I thought people might be
interested.
I find that each subrequest get's dispatched and seems
to be better isolated, however the return seems to
always be undefined. Here's my example:
package myapp::Controller::regions;
sub base_region :Path
{
my ( $self, $c ) = @_;
$c->stash->{one} =
$c->sub_request('/regions/region_one')
|| 'nothing from one';
$c->stash->{two} =
$c->sub_request('/regions/region_two')
|| 'nothing from two';
my $response = sprintf(
"Region 1: %s, Region 2: %s",
$c->stash->{one},
$c->stash->{two},
);
$c->response->body( $response );
}
sub region_one :Local
{
my ( $self, $c ) = @_;
$c->response->body('region one');
}
sub region_two :Local
{
my ( $self, $c ) = @_;
$c->response->body('region two');
}
The result when I point the browser to /regions is:
"Region 1: nothing from two, Region 2: nothing from
two"
I placed some debug code inside the plugin to see what
is going on and it does seem like the body is empty.
I can see in my debug screen that each subrequest gets
called. My debug output looks like:
[info] *** Request 1 (0.333/s) [7886] [Fri Sep 29
19:15:57 2006] ***
[debug] "GET" request for "regions" from
"10.176.11.153"
[debug] Path is "regions"
[info] *** Request 1 (0.333/s) [7886] [Fri Sep 29
19:15:57 2006] ***
[debug] "GET" request for "regions/region_one" from
"10.176.11.153"
[debug] Path is "regions/region_one"
[info] *** Request 1 (0.333/s) [7886] [Fri Sep 29
19:15:57 2006] ***
[debug] "GET" request for "regions/region_two" from
"10.176.11.153"
[debug] Path is "regions/region_two"
Now, is this how we want it to work? I can rewrite
this in the form of a few tests but I'm not sure if
anyone other than me cares :)
Just curious, is there anyone else that is trying to
do portal-like development with Catalyst? What I mean
by this is that each page is broken into regions which
each have there own controller to handle GET/POST/PUT
etc and each dispatches through to a view. This way
you make it easier to build pages that are
aggregations of content and also to enable AJAX style
dynamic updates of page sections without reloading the
whole page.
--john
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Catalyst
mailing list