Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Mason2: Where is support for <%attr> gone? <%class> not an alternative for my need

by flowdy (Scribe)
on Jul 14, 2014 at 13:30 UTC ( [id://1093551]=perlquestion: print w/replies, xml ) Need Help??

flowdy has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I am planning the migration from HTML::Mason (version 1) to Mason version 2. It is a website of approx. 1000 pages most of which contain static html only. Mason 1 is very good at wrapping the contents of the files in a frame providing navigation and the usual stuff. Some pages have got additional intelligence that is realized with plain perl.

All pages have got a page title set:

<%ATTR> title => "My humble web page" </%ATTR>

You might ask why it's not simply static <h1>-Tags. But I realized the page title as an attribute due to the fact that this information, among other, is needed for our institutional web management system.

Now, the equivalent Mason 2 code would be:

<%CLASS> has title => (is => "ro", default => "My humble web page", init_arg => + undef); </%CLASS>

'ro' means read-only, init_arg => undef makes sure the title cannot be reset to some 'title' param passed by URL query part. However, I see two problems with this approach:

  • The need to touch and update all those pages. To be safe, this would probably be done manually.
  • The pages are maintained by our web editors who are not authorized to touch or change code, yet to encounter as little as possible of what resides of it in the pages, but in fact <%CLASS> blocks contain plain perl, therefore they are potentially unsafe.

Is there something I missed in the documentation? Already considered subclassing Mason::Compilation, overwriting its unnamed_block_types to have it cover <%attr>, but then I have not the slightest clue of how to associate any handling code with it, and the code jungle in that module is very impressive, leaves me reluctant to duplicate and change any piece of it.

Unfortunately, CMS are not considered an option for us. Only Mason provides for enough flexibility regarding our needs.

Oh dear monks, I hope you can help me here.

Regards,
flowdy

Replies are listed 'Best First'.
Re: Mason2: Where is support for <%attr> gone? <%class> not a alternative for my need
by Anonymous Monk on Jul 14, 2014 at 20:47 UTC
    Why do you want mason2?

      Thanks for that good a point. The MasonHQ site reads:

      Version 1 of Mason (HTML::Mason) has been around since 1998. It is in wide use and is very stable. However it has not changed much in years and does not use much in the way of Modern Perl.

      Version 2 of Mason (Mason), along with Poet, is being actively developed and has a much more modern architecture. If you are just starting out, we recommend you give Mason 2 a try.

      So, in the course of remaking a webserver, while keeping much of the content, we focussed on Mason 2 in the first place. There are more advantages: Independence from the web server (doesn't depend on modperl, which is obsolete itself and, after all, does not run on Apache 2.4 anyway), automatic tests, to name two. Plus, when a version is actively developed, you can be sure that older versions get more and more neglected (security updates). This can easily be seen since Open Source projects haven't usually much capacity.

      -- flowdy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1093551]
Approved by marto
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found