Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

newbie question: Mason, CGI::App, MVC

by nop (Hermit)
on Sep 03, 2002 at 15:45 UTC ( #194800=perlquestion: print w/replies, xml ) Need Help??
nop has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I've just started reading about Mason and am getting interested in the technology. My early sense is Mason offers a powerful way to build modular web pages via components. Components can have perl in them, though I agree with the assertion that too much code isn't the best idea. I also see that Mason can interact nicely with apache::session to handle state.

Here's my question: how do folks using Mason handle application logic? I've built a hand-rolled version of CGI::Application that meets my needs and used TT2; do I do the same w/ Mason? Or does Mason have logic routing code aspects to it?

Also, can anyone offer examples / links / suggestions to using Mason in a model-view-controller design?

These are new areas to me; apologies if my question reflects that. Thanks --


Replies are listed 'Best First'.
Re: newbie question: Mason, CGI::App, MVC
by Arguile (Hermit) on Sep 03, 2002 at 16:15 UTC
Re: newbie question: Mason, CGI::App, MVC
by nop (Hermit) on Sep 03, 2002 at 17:25 UTC
    Thanks, Arguile! Perin's article was right on track, and helps me rephrase my question. Perin states:
    The pipeline style does all the work up front in a standard CGI or mod +_perl handler, then decides which template to run and passes some dat +a to it. The template has no control flow logic in it, just presentat +ion logic, e.g. show this graphic if this item is on sale. Popular sy +stems supporting this approach include HTML::Template and Template To +olkit. The callback model works well for publishing-oriented sites where the +pages are essentially mix and match sets of articles and lists. Ideal +ly, a site can be broken down into visual ``components'' or pieces of + pages that are general enough for an HTML coder to recombine them in +to entirely new kinds of pages without any help from a programmer. [snip] The pipeline model is more like a traditional model-view-controller de +sign. Working this way can provide additional performance tuning oppo +rtunities over an approach where you don't know what data will be nee +ded at the beginning of the request. You can aggregate database queri +es, make smarter choices about caching, etc. It can also promote a cl +eaner separation of application logic and presentation. However, this + approach takes longer to get started with since it's a bigger concep +tual hurdle and always involves at least two files: one for the Perl +code and one for the template.
    So my question is:
    am I on the wrong track to consider Mason when I want to use a pipeline model, eg M-V-C?
      <blatent whoring on my part>

      Disclaimer: I'm a big AxKit fan.

      If you are really into the pipeline style of web programming, also take a look at AxKit/Cocoon. They seem to be more geared towards true app logic pipelines instead of templating. Maybe it's just me, and the examples on Mason never stood out as pipelining vs. includes. Could anyone who has used both shed some light?

      Introducing AxKit
      XSP, Taglibs and Pipelines
      Taglib TMTOWTDI

      Getting started is a little slow, but the benefits later are well worth it.

      </blatent whoring on my part>

      Updated: s/Cacoon/Cocoon/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://194800]
Approved by Arguile
[haukex]: I think you're right, I think Pod::Simple is the preferred parser now
[haukex]: But I was just using it as an author test anyway
[Corion]: haukex: Aaah - I thought you were still running these tests on every machine, but you only run these as author or Devel::Cover tests
[Corion]: haukex: Yeah, I think back then I used Test::Inline, which used a pod parser that was going through some changes and I didn't want to cater for all the various versions and thus stopped testing the Pod completely
[choroba]: I usually do this with presentations
[Corion]: But now I think statically (re)generating the Pod tests is a saner approach, and likely I'll regenerate the tests either in Makefile.PL or from xt/ but have them live below t/
[choroba]: I keep the snippets in files of their own, and use a Makefile to syntax highlight them and insert them into slides, while also running them and inserting the output if required
[Corion]: choroba: Ooooh - I didn't think of that! I write my presentations as POD and if it "roughly" looks like Perl code, I should also syntax-check that...
[haukex]: Yes sorry I don't run them all the time, my POD tests are only run as author tests (and are excluded when I'm using Devel::Cover)
[Corion]: choroba: Hmm - no, I keep the snippets inline, but as my framework also has support for capturing output etc., maybe I should do the same...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2017-02-27 12:25 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.