I have been playing with Catalyst a bit (and who hasn't). It is a wonderful framework for getting going quickly with web development. However, particularly on the Model side, and to a certain extent on the View side, I would like to build my own models and views. I was hoping someone could clarify the inheritance pattern. The code for two different CPAN model modules is given here. One uses NEXT for creating the object and the other uses a different method. Which is the "correct" idiom (if there is one) and why?
package Catalyst::Model::CDBI::Plain;
use strict;
our $VERSION = '0.03';
use base qw[Class::DBI Catalyst::Base];
sub new {
my ( $class, $c ) = @_;
return Catalyst::Base->new( $class, $c );
}
1;
versus this:
package Catalyst::Model::DBIC::Plain;
use strict;
use base qw/Catalyst::Model DBIx::Class::Schema/;
use NEXT;
sub new {
my ( $self, $c ) = @_;
$self = $self->NEXT::new($c);
return $self;
}
1;
One quick and dirty Model class that I would like to use is DBIx::Simple (I know, not a model, but it works for some simple designs). Can folks suggest code for a generic DBIx::Simple Model (I have one that works and simply returns a new DBIx::Simple instance)?
Thanks,
Sean
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.