On Wed, Apr 15, 2009 at 7:41 PM, Kyoko Shikamata
<[email protected]>wrote:

> Hi,
>
> How do you design web parts ?
>
> I'm using C::P::SubRequest in my project.
>
> Ex:
> <html>
> <body>
>  <div id="main">
>   Hello
>  </div>
>  <div id="right">
>    [% c.subreq('/parts/ranking') %]
>  </div>
> </bod>
> </html>
>
> package MyApp::Controller::Parts::Ranking;
> ......
> sub index : Local {
>    my ( $self, $c ) = @_;
>    $c->stash->{data} =
>         $c->model('Products')
>         ->search({},
>          {order_by => 'sales DESC' });
>    $c->stash->{template} = 'parts/ranking.tt';
>    $c->forward($c->view('TT'));
> }
> 1;
>
> But,
> When I use C::P::PageCache, C::P::SubRequest sometimes is not executed.
> I cannot find the cause.
> So, I'm looking for other methods.
> Pls teach me the good design.
>
>
> I apologize for my poor English.
> ---
> Kyoko Shikamata
>
>
Why are you using a subrequest, rather than forwarding to the controller and
allowing that to populate the stash?  Unless you have a reason for the
subrequest, it is usually better to simply generate all data in the stash,
and have the template render out the data.  So your main controller would
simply do $c->forward('/parts/ranking') and include the template for
processing ([% PROCESS "parts/ranking.tt" %])

SubRequest makes an entirely new request inside, blocking the calling
request until the other is done.  If you want this type of design you
probably should be using Catalyst::View::Component::SubInclude as a
framework, rather than doing it on your own.  The benefits of this are when
you launch, you can use something that supports ESI and cache the entire
page but only call the individual subcomponents.

I do think that your design may be overly complex, but without knowing more
details I cannot help any further.

(I notice you have a .jp email address, so I'll mention that I'll be giving
a Catalyst talk in Akihabara on April 21st, by the way.
http://japan.perlassociation.org/event/jpa-seminar-01 -- the JPA is
translating my slides)

-J
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to