I'm tinkering with having a TT singleton under mod_perl, and tweaking
INCLUDE_PATH, and my knowledge is insufficient to tell me if this will
work.
Background:
Most of the apps I develop are of a "one base app module, many instance
script cgis to give parameters, and many template trees" variety (using
CGI::App). For example, I might write a "contact list" application, and
different divisions and units will use it. The designer sets the proper
parameters in the cgi, and points it to the customized set of templates.
Quite often, only one or two templates need to change. So I use what I
call "cascading" directories. If an instance is told to use
/foo/bar/baz/ for it's templates, for each named template it checks
/foo/bar/baz, then /foo/bar/ then /foo, then / until it finds it. So I
can have a default set of templates in /templates/thisapp/, and
customize one or two templates in that set for a particular instance at
/templates/thisapp/bobs/
Currently I do this with an ugly plugin. I can easily switch to using
PROCESS if I stuff the correct paths onto INCLUDE_PATH.
I want to have a singleton Template object to keep mod_perl from
consuming a second ton of memory. (the code is run under
Apache::Registry) My thought is that I'll have a simple
object something like:
my $object;
sub new {
# return $object if defined
# create TT object otherwise
}
sub output {
# stuff INCLUDE_PATH
# call process() on TT object
# unstuff INCLUDE_PATH
}
But my concern is that I don't understand singletons and shared memory
over multiple child processes enough to know that my output() will be an
atomic action (at least within the scope of each method call). Will
this work, or will one child be modifying the config of the object when
another child is calling it?
Thanks in advance
--
SwiftOne / Brett Sanger
[EMAIL PROTECTED]
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates