At 11:00 18/01/03, Simon Wilcox wrote:
So this is one primitive way of creating the "controller" object in the Model-View-Controller pattern for web apps.On Sat, 18 Jan 2003, Simon Wistow wrote:> > It's been a while since I've done a full blown web app, especially with > a templating system, and I'd appreciate some advice. > > Single CGI with a load of if/else statments based on mode or something > ... > > my $q = new CGI(); > my $mode = $q->param('mode'); > > my $template = Template->new($config); > > my $template = 'default' > my $vars = {}; > > if ($mode eq 'foo') { > > $template = 'foo'; > $vars->{quux} = 'something'; > > } elsif ($mode eq 'bar') { > > $template = 'bar'; > $vars->{quux} = 'something else'; > $vars->{quirk} = 5; > } > > $template->process($template, $vars) > || die $template->error(); > > > Or individual CGIs for every single template? > > There are quite a few templates, about 20 or 30 if that makes a > difference. I've been converted to using dispatch tables for this sort of thing. See Ziggy's paper at: http://www.usenix.org/publications/login/2002-06/pdfs/turoff.pdf
Are there any off the shelf MVC systems? I know of TemplateToolkit and other View systems, and DBI::Class and similar can be used for Model side of things, but the controller is always missing in perl.
For instance what if you wanted to do a role based authentication/authorisation system. Does everyone write if from scratch each time?
Alex
PS My mail package displayed both the authors of this thread as "Simon Wi..." so it is no wonder I have difficulty telling them apart.
Available for java/perl/C++/web development in London, UK or nearby. Apache FOP, Cocoon,
Turbine, Struts,XSL:FO, XML, Tomcat, First meeting free.http://www.OWAL.co.uk/