On Thu, Jan 24, 2002 at 05:56:25PM -0800, Bill Moseley wrote:
> For example, in a .ttreerc file I might have:

[...]

> But I also need some of those same settings in my source files such as in
> CGI scripts:

Yes, it's a minor failing that I've come across myself several times.  The
correct way to solve this problem is, I think, to have a Template::Profile
module which encapsulates all the information required to generate a Template
object.  It should have methods to read/write configuration files that could
then be used for ttree, CGI scripts, Apache mod_perl handlers, etc.

Until that day, one solution is to use ttree to generate your ttree 
configuration files and also a simple Perl module which instantiates
your Template object in a given way. 

For example:

my/ttreerc

   src  = [% project.src %]
   lib  = [% project.lib %]
   dest = [% project.dest %]
   pre_process = [% project.pre_process %]
   .
   .
   .

My/Template.pm

   package My::Template;
   use Template;
   
   sub new {
       Template->new({
           INCLUDE_PATH => [ '[% project.src %]', '[% project.lib %]' ],
               PRE_PROCESS  => '[% project.pre_process %]',
           .
           .
           .
       });
   }
 
You process these files once using your 'project' ttree configuration 
(or any time you need to change values) and this generates your 'runtime' 
ttree configuation and Perl module.

Then you just change your CGI scripts to do this:

  my $tt = My::Template->new();

> So, in other words, run something like:
> 
>     ttree -f $HOME/siteA/ttlib/config --define conf=foo --getconfig=conf
> 
> so it would use the "foo" config section, and read its config options from
> %conf.
> 
> Anyone follow what I'm asking?

Yes.  And it scares me  :-)

The sticking point for anything and everything related to ttree is the 
AppConfig module which does the config file and command line magic.  I
haven't updated it in years and I really, really, really should.  I must
have 100+ emails in a folder with patches, suggestions, improvements, etc.,
that I haven't got around to applying.  I just need to find a week when 
I've got nothing better to do...

In fact, that's just the tip of the iceberg.  ttree is a hack and it needs
to be burnt down and rebuilt from the ground up.  But there's no point
doing that until TT3, and that will come along just as soon as I find 3 
months when I've got nothing better to do...  

Ho hum.  Big wheels keep on turning.... but slowly :-)

A



Reply via email to