[Catalyst] Dispatching based on path and host/domain

Matt Pitts mpitts at a3its.com
Tue Apr 22 14:24:17 BST 2008


> -----Original Message-----
> From: Curtis Fletcher [mailto:curtis.fletcher at pharmaventures.com]
> Sent: Tuesday, April 22, 2008 5:23 AM
> To: The elegant MVC web framework
> Subject: RE: [Catalyst] Dispatching based on path and host/domain
> 
> > -----Original Message-----
> > From: Matt Pitts [mailto:mpitts at a3its.com]
> > Sent: 22 April 2008 03:06
> > To: The elegant MVC web framework
> > Subject: RE: [Catalyst] Dispatching based on path and host/domain
> >
> > > You've probably heard this before on the list, but...
> > >
> > > Ideally, you shouldn't have enough code in your Controllers
> > to justify
> > > "sharing" the app across domains that need different
functionality.
> > The
> > > meat of the app should be in the Models, then you can just run
> > multiple
> > > Cat apps - one with Cart controllers and one without - that use
the
> > > same
> > > "shared" Models.
> 
> Absolutely right, my controllers are much, much too heavy. This all
> came
> from "learning as I went" and I distinctly remember the point at which
> I
> gave up trying to put business logic in the model. At the time there
> seemed to be minimal if any examples that illustrated the model being
> anything other than an adaptor for DBIx::Class::Schema so I just
> figured
> I was mistaken in my attempt to do so.
> 
> So could I ask, now I know a little more than I did then, Does
everyone
> here subclass DBIx::Class::Resultset (a-la
> http://catalyst.perl.org/calendar/2007/16) for their business logic
> specific methods? (Well those that use DBIx::Class as their model
> anyway)
> 
> Thanks for the Help Matt, it's certainly made me think.

You're very welcome.

As far as DBIC goes, yes I subclass DBIC::RS - actually I've built out a
common DBIC "library" that I use in my DBIC models that provides common
base classes for DBIC and DBIC::ResultSet, and a standard set of
Exceptions. The library provides come really common filtering facilities
for my apps like "active" flag and "valid_from"/"valid_to" date ranges
for records.

I then use a custom ResultSet class via __PACKAGE__->resultset_class
(that subclasses the library's base RS class) in almost everyone of my
DBIC classes, because eventually I come to a point when I need to
implement custom RS methods.

Something like...

package MyCustomer::Schema::Cart;
use base qw/ MyCompany::DBIC::Base /;

...

__PACKAGE__->resultset_class('MyCustomer::Schema::CartRS');


...

1;

package MyCustomer::Schema::CartRS;
use base qw/ MyCompany::DBIC::ResultSet /;

...

1;

v/r
-matt pitts



More information about the Catalyst mailing list