* Perrin Harkins <[EMAIL PROTECTED]> [2002-06-18 10:00]: > Douglas S. Sparling wrote: > >To be more specific, I'm not sure how to set up > >TT2ServiceModule to handle different URIs. > > > >I can get the sample code to work: > > > >PerlModule Apache::Template > >PerlModule My::Service::Module > >TT2ServiceModule My::Service::Module > ><Files *.html> > > SetHandler perl-script > > PerlHandler Apache::Template > ></Files> > > > >But I'd like to run different code depending on the > >URI. > > I think you can just say something like this: > <Location /tom> > TT2ServiceModule Bombadil > </Location>
The way Apache::Template is setup, Location based directives do random things, so this isn't as useful in practice as it is in theory. > You read me correctly: I was suggesting moving some things out of > plugins into the service module. You can still do that with a single Service module, of course; all it has to do is be able to delegate correctly. Changing Service modules per requests under Apache::Template will lead to unpredictable results. > Alternatively, you could make your Service module examine the request > object and run different code appropriately. A better option, in this case, is to use something other than Apache::Template, which would dispatch to the appropriate Service module. At this point, you are doing more than Apache::Template was designed to do, which is pass $r->filename to a Service module. > Your plugin solution may work fine if your pages are not interactive. > However, if you find yourself writing a plugin that needs to change > which template is being run or discard previously generated HTML, > that's usually a sign that you're doing something in the wrong place. I agree; if this is what you're doing, then you need to consider a custom handler module, and not use Apache::Template. (darren) -- Responsible behavior is the result of a socialization process.
