[cgiapp] Proposal: Change CGI::Snapp's base class from Hash::FieldHash to Moos (sic)

Ron Savage ron at savage.net.au
Tue Nov 20 17:48:27 EST 2012


Hi

I am planning to change CGI::Snapp's base class from Hash::FieldHash to 
Moos (sic).

I understand this will cause some disruption to users of CGI::Snapp (if 
any :-), but there will be a number of benefits. And it's these benefits 
which has convinced me to propose this.

The new CGI::Snapp would jump to V 2.00, to indicate a significant 
internal change. It's currently V 1.03.

Benefits:

o Moos is extremely light-weight (as is Hash::FieldHash).

o Moos (naturally) supports inheritance, with 'extends'.

o Moos supports consumption of roles, with 'with', if you have 
Role::Tiny installed. It's name says it all.

This means, e.g., the internal logger would become CGI::Snapp::Logger, a 
role.

o The Moos syntax is, of course, Moose-like.

o Using Moos means if you use a MVC code structure, and were previously 
having difficulty deciding if you should use Hash::FieldHash or Moose 
(sic), or similar in your controllers, etc, you could now use Moos there 
too.

This particularly appeals to me, since I've been using Moose in all 
three, M, V, and C, and the mismatch with Hash::FieldHash has always 
bugged me.

Unifying them has other benefits, since I have some modules which will 
dove-tail nicely by switching to Moos as well:

o Local::Config. This loads a config file per project. It wraps 
File::HomeDir to load a file using the project's name.

o Local::Connector. This uses Local::Config's per project file to wrap 
DBIx::Connector to create a project-specific dbh.

This can then be passed to any code in the project, minimizing the # of 
dbhs used (if that appeals to you).

o Local::Logger, which uses the project-specific dbh from 
Local::Connector, since my projects all log to a db.

The point of these is to be able to drop and create db tables without 
needing DBIx:Class. Then, constant tables can be populated and exported 
to HTML and CSV, still without DBIx::Class.

Finally, when the tables exist, I can use DBIx::Class itself to generate 
the source code of the Schema::* modules for use by other classes, e.g. 
the M and V in MVC.

As I type this email, the idea is growing on me more and more.

So, if you have any comments, now is the time to speak up.

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


More information about the cgiapp mailing list