in reply to Why can't mod_perl+Mason just work?

You'd think, with PHP racing ahead of Perl in popularity for small/medium-sized web development projects, that the movers and shakers behing PHP's closest competitor - mod_perl+Mason - would have made it a little easier by now to get things up and running.
Ignoring all of your technical difficulties, why are you so focused on embedding executable code inside html pages? Generally speaking, the common consensus is that you should seperate the "business code" from the "display code", in what is commonly called MVC. Embedding exeutable code in web pages doesn't really go along with this. Why not just teach them the proper way to design web applications from the beginning?
  • Comment on Re: Why can't mod_perl+Mason just work?

Replies are listed 'Best First'.
Re^2: Why can't mod_perl+Mason just work?
by gunzip (Pilgrim) on Aug 12, 2004 at 23:07 UTC
    Thanks. I hadn't considered the alternative since so many have recommended Mason and Embperl. Which are the best modules for this approach? Simon Cozens put out something recently along these lines, I believe.
      You don't need *any* modules to do this sort of thing. Just structure your code so you have one section that displays output and another section that decides what to output and a third section to link the two.

      However there are several modules that make this sort of thing easier. My current favorites are CGI::Application and HTML::Template. HTML::Template is a basic, but extremely fast and well designed templating engine that takes basic templates and fills them with paramaters. CGI::Application is a parent class that makes designing CGI state machines much simpler. Together they let you design clean, well structured code, so that each portion focuses on one specific task.

      CGI::Applications work by having several "run modes", which basically states in your state machine, if you think of it that way. Typically every page that is displayed to a user is a run mode, and typically these run modes invoke html::template for the actual html generation. In this case, the specific run mode is the "Model" code, while the template you are displaying is the "View" code, and the CGI::Application base class provides the "Controller" code.
      Check out Re: Why CGI::Application (and its replies) for how to design a C::A application. There are tons of good C::A nodes on Perlmonks.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested