"Rafiq Ismail (ADMIN)" wrote:
> Hi, > > I'm building an MVC architecture site and have hit a design issue. I have > varoius Control subclasses which relate to different templates with > different behaviour. Now my problem is that I have to assign which > Subclass I want to instantiate, based on the script and params. I my last > effort I went for a Shared datastructure holding (script, control module > pairs) which then allowed one to be dynamically "eval 'use..'"'ed in the > main content handler. I found that clunky. I'm building from scratch > again and am thinking of just firing up a template and allowing the > control to be loaded INTO the view as a template toolkit plugin. What I > hate about this is that I'm surrendering my View layer. > > Is there a neat way of dynamically loading in the appropriate control > subclass? Something proven and widely used. > A while back I was on this same quest. You didn't say if you were using CGI or mod_perl. For CGI, I ended up using a CPAN module named "CGI::Application". It is more simplistic than you describe in that a method is invoked based on a query parameter, rather than a command class being instantiated and then invoked. "CGI::Application" is tightly coupled to "HTML::Template", but I have created a subclass that makes life convenient for Template-Toolkit. regards, Brian > > Cheers, > > Fiq > > "__ __ _ __ __ > | \/ | ___ __| | ___ _ __ _ __ | \/ | __ _ _ __ > | |\/| |/ _ \ / _` |/ _ \ '__| '_ \| |\/| |/ _` | '_ \ > | | | | (_) | (_| | __/ | | | | | | | | (_| | | | | > |_| |_|\___/ \__,_|\___|_| |_| |_|_| |_|\__,_|_| |_| > a pathetic example of his organic heritage" > - Bad Religion > > _______________________________________________ > templates mailing list > [EMAIL PROTECTED] > http://www.template-toolkit.org/mailman/listinfo/templates
