[Catalyst] Context sensitive template locations

ben.norman at qmunity.net ben.norman at qmunity.net
Wed Nov 30 04:08:11 CET 2005


Quoting ben.norman at qmunity.net:

> 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
>
This one is tested with a really vanilla site.
xxx at xxxxxx:/opt/xxxxx/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} || [ $root,
"$root/base" ];
<     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,301d291
<       while (@{$self->include_path}) {shift @{$self->include_path};};
<       push @{$self->include_path}, $c->config->{root} . '/' .
$c->request->{match} if $c->stash->{add_match};
<       push @{$self->include_path}, @{$self->init_include_path};
<


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Catalyst mailing list