[Catalyst] Mason + DBI + Catalyst?

J. Shirley jshirley at gmail.com
Mon May 25 23:00:38 GMT 2009


On Mon, May 25, 2009 at 3:35 PM, Daniel Carrera <
daniel.carrera at theingots.org> wrote:

> Hello,
>
> I'm starting to learn about Catalyst. I'm looking for a MVC framework for
> Perl. My first concern is that for views, Catalyst seems to be really gea=
red
> toward TemplateToolkit and I don't really like TT. I think I like Mason (=
no
> real experience though). I know that Catalyst can work with Mason, but all
> the documentation talks about TT. And if a feature is not documented, as =
far
> as the user is concerned, it might as well not exist.
>
> Is there any good documentation for Catalyst that is based on Mason?
>
> I have a similar (but lesser) concern about the database module. Catalyst
> documentation seems to focus on DBIx::Class, but looking at DBIx I get the
> feeling that it just tries to hide SQL. This seems like a pointless
> exercise, since SQL is easy enough (and the Perl replacement is not easie=
r).
> But more importantly, I worry about losing control. In my application I n=
eed
> to do moderately complex queries, like joining three tables, or using a
> temporary tables. Once again, I know that Catalyst is capable of using DB=
I,
> but if this is not well documented, it makes it that much harder for me to
> use Catalyst. And so far, the documentation seems to only talk about
> DBIx::Class.
>
> Any suggestions?
>
> Thanks.
> Daniel.
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>


Hi Daniel,

Catalyst is not geared towards TT, it is just that more Catalyst users use
TT so more documentation and articles are written centered around TT.  The
Mason view works just fine, and won't cause any problems.  However, if you
try to use Mason's framework system in conjunction with Catalyst, things
will get weird quickly.

Rather than Catalyst being geared towards TT, I would say Mason is geared
towards being a framework :)

The view should just be thin templates, in that regard I would recommend
using Catalyst::View::MicroMason (
http://search.cpan.org/~jrockway/Catalyst-View-MicroMason-0.05/lib/Catalyst=
/View/MicroMason.pm)
which wraps Text::MicroMason (Mason template syntax without the
"framework").

There really isn't a lot of documentation, because nothing aside from the
path to the template is really related to Catalyst.

By default, your template rendered will be the action path name (in a
controller called "Foo::Bar" with an action called "baz" the template would
be "root/foo/bar/baz.mc").  This setup (which just sets
$c->stash->{template}) happens in Catalyst::Action::RenderView

Regarding DBIC (not DBIx, but that's a common naming mistake), your concerns
are certainly valid.  I'll address it sort of bullet-point style, but if you
want DBI then just use Catalyst::Model::DBI.  I would recommend taking a day
to play with DBIx::Class though, as it is quite nice.

DBIC and SQL::Abstract handle complex queries very well.  I have several
queries that span 8+ tables, with various join conditions.

You can have arbitrary SQL in a custom result source just fine.

Being able to chain resultsets makes it much much easier than using straight
SQL, and you write less code.  If you have a query you've constructed called
$query, and lets say you now only want active records you can do $query =3D
$query->search({ active =3D> 1 });  In this way you can filter many things
incrementally.

I'll second hdp's opinion that you are expecting more from Catalyst.
Catalyst is glue, nothing more.  If you want DBI, you can use
Catalyst::Model::DBI and get a $dbh object and put everything in your
controller and have a rather ugly application that isn't really MVC.  But,
that's my opinion -- on a technical level it works fine.

A big reason you may not find the documentation you are looking for is that
glue is just a really simple tool.  It's all the other tools that are hard
to use.

-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090525/2e976=
54c/attachment.htm


More information about the Catalyst mailing list