[Catalyst] Context sensitive template locations
ben.norman at qmunity.net
ben.norman at qmunity.net
Tue Nov 29 02:23:00 CET 2005
Quoting Matt S Trout <dbix-class at trout.me.uk>:
> On Fri, Nov 25, 2005 at 03:19:48PM +0100, Zbigniew Lukasiak wrote:
> > > > sub unshift_paths {
> > > > my($self, @paths) = @_;
> > > > unshift(@{$self->include_path}, @paths);
> > > > }
> > >
> > > Don't you want to rebuilt the path each time? That looks like a
> > > small memory leak
> >
> > Hmm. The question is where to add the cleaning code. Perhaps to the
> > process method? How would this work with subrequests? I cannot see
> > other situations when process would be called multiple times in one
> > request.
>
> Quite possible not, but the Template object is persistent across requests
> for performance. So after 1000 requests you're going to have a 1000
> entry include path.
>
> Please read the Catalyst::View::TT source for details.
>
It did add to the include_path every request. I came up with the following diff.
Im not saying its needed yet, Im just trying to contribute to the cause. It
also includes the magic bit someone mentioned ie it will prefix the current
request match value to the list of include_paths after the root directory.
thanks
Ben
/opt/positions> diff ../perl/Catalyst/View/TT.pm
/usr/lib/perl5/site_perl/5.8.7/Catalyst/View/TT.pm
12,13d11
< __PACKAGE__->mk_accessors('include_path');
< __PACKAGE__->mk_accessors('init_include_path');
232,233d229
< my @init_include_path = @{$arguments->{INCLUDE_PATH}};
< my @include_path = @init_include_path;
237a234
> INCLUDE_PATH => [ $root, "$root/base" ],
239,240c236
< %{$arguments},
< INCLUDE_PATH => \@include_path,
---
> %{$arguments}
274,275d269
< $self->include_path(\@include_path);
< $self->init_include_path(\@init_include_path);
298,302d291
< if ($c->stash->{add_match}) {
< while (@{$self->include_path}) {shift @{$self->include_path};};
< push @{$self->include_path},
($c->config->{root}.'/'.$c->request->{match}, @{$self->init_include_path});
< }
<
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the Catalyst
mailing list