[Catalyst] RFC and first draft for page regions

John Napiorkowski jjn1056 at yahoo.com
Thu Oct 12 19:51:15 CEST 2006


Hi,

In the past several people have talked about the idea
of augmenting catalyst so that you could associate
actions as subarea or regions of a controlling action.
 This would make it easier to break up a page for the
purposes of making portal like websites and for easing
work to make AJAX style content areas in a page.

I've made a first stab at that with the attached code.
 It's pretty dumb, just a plugin and a model but I'm
hoping interested people can take a look, give me some
comments and help make it act the way we'd like it to.

Basically there is a plugin that looks for a
:Regions(xxx) attribute on your actions.  That
attribute should contain a list of the actions that
you want as regions of the page.  Right now they need
to be actions in the current controller:

package myapp::Controller::pages

sub page :Local :Regions(toc,content,ad) {}

sub toc :Local {}
sub content :Local {}
sub ad :Local {}

The plugin override the dispatch  phase to create a
bunch of hash refs in the stash, with each stash item
based on the action name:

$c->stash->{PagesToc};
$c->stash->{PagesContent};
$c->stash->{PagesAd};

Those stash items are available to your view.  Each
one currently is a ref to a hash that has some
callback to get the page content.

$c->stash->{PagesToc}->{link}; #like $c->uri_for on
the action

$c->stash->{PagesToc}->{action}; #the action obj.

$c->stash->{PagesToc}->{response}; # Uses LWP to get
the url specified by the action. Right now this only
supports GET.

So if you use this then in Template toolkit you could:

[% PagesToc.response.content %]

and you should drop the region there.

This relies on a simple LWP model.  You'll need to
stick both in your path to get this working.

Right now this is just using LWP to generate a full
subrequest, but obviously this is not ideal.  Actually
I'd like this to be similar to the subrequest plugin
but it doesn't have to totally isolate the subrequest
from the requesting context.  I think it would be best
if the region behaves similar to chaining, where the
current context in preserved, but should reset the
context for each region.

Anyway I don't know if anyone has comments or thoughts
on the code.  As I said several people at different
times have mentioned interest in such a thing and I
need it for my application.  I'd like mostly to get
some ideas/thoughts from someone that understand the
dispatcher so that I can fix the LWP call soonest.

Thanks!

John

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: http.pm
Type: application/octet-stream
Size: 3643 bytes
Desc: 3094465588-http.pm
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20061012/c1ccac1f/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Regions.pm
Type: application/octet-stream
Size: 2864 bytes
Desc: 917680603-Regions.pm
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20061012/c1ccac1f/attachment-0003.obj 


More information about the Catalyst mailing list