Beginners - never use Mason::Plugin::LvalueAttributes. Why such statement?

Sharing my experience (read: my own "stupidity" ).

A year ago I made one small application. Was  simple app - so, at the
installation I installed/enabled the Mason::Plugin::LvalueAttributes too.

Yes, a year ago I read the clear warning in its doccu.

Standard Moose setter features such as type checking, triggers, and
coercion will not work on Lvalue attributes. You should only use this
plugin when the convenience of the Lvalue attributes outweighs the need for
setter features.

Because, the app has simple "logic" - using the LvalueAttributes was
welcomed.

Now, after a year, I start to extend the application. In one component I
needed something like this  (/data.mi):

<%class>
    has 'datafile';
    has 'data' => (builder => '_example_builder', lazy=>1);
    method _example_builder {
        return {file => $self->datafile};
    }
</%class>

One attribute depends on another attribute - typical use of Moose's 'lazy
builder'.

And ... (now I understand - of course ) - it did'nt work - the 'data'
didn't initialized. (no error message - simple, it remains "undef").

After a quite long debugging ( I'm not an Perl / Moose - guru - it took me
a LONG time) I found that the problem is caused by
Mason::Plugin::LvalueAttributes . Although the components didn't uses $.var
= "something"; - it is enough to be enabled the Plugin and the builder=>...
and lazy doesn't work.

This is a bitter experience . It is not the fault of the plugin-author - he
wrote in the manual an clear warning , but after a year - finding the bug
(for a beginner like me) was a difficult task.

Therefore, my recommendation for the beginners : Do not use
Mason::Plugin::LvalueAttributes - you'll avoid the mistakes - which took
myself too long time to find.

ak.

Ps: English is not my native ... The post is not againist the plugin. It is
great. Only can cause much troubles, if you forget disable it. (and the
disabling mean, re-edit every component what uses the $.var =
"something"... Maybe, this post helps to someone in the future... ;)
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to