[Dbix-class] using DBIx::Class::CDBICompat

John Goulah jgoulah at gmail.com
Tue May 22 21:59:37 GMT 2007


On 5/22/07, John Goulah <jgoulah at gmail.com> wrote:
>
> On 5/22/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
> >
> > On Tue, May 22, 2007 at 02:42:36PM -0400, John Goulah wrote:
> > > >A class that uses base DBIx::Class::ResultSet and then just do
> > > >
> > > >__PACKAGE__->resultset_class('My::ResultSet::Class');
> > > >
> > > >in any table class that needs it. ResultSetManager is just a
> > convenience
> > > >syntax to that, and causes enough problems in more complex cases
> > there's
> > > >serious consideration being given to deprecating it in favour of
> > saner
> > > >syntax.
> > >
> > >
> > >
> > > That works fine, but I would rather scope the package under myDB
> > rather than
> > > MyApp, but when I put the ResultSet dir under myDB directory I get
> > "Cannot
> > > load schema class" errors (under MyApp its fine).  I assume its trying
> > to
> > > load this class as a table class.  Is there any way around this?  If
> > not
> > > where is the recommended place to put these?   It seems best to keep
> > it
> > > close to the DB classes, but I'm not sure Catalyst will let me.
> >
> > That's because you've called load_classes with no arguments, see the
> > ::Schema
> > docs.
>
>
>
> good catch.
>
>
> What I'd tend to do is have 'MyApp::Schema::Foo' and then
> > 'MyApp::ResultSet::Foo' - putting the DB in 'MyDB' is awful design, your
> >
> > project should only use *one* top-level namespace.
>
>
>
>
> Fair enough, and good to know.
>
> The only reason I did it that way is because I'm new to Catalyst and thats
> what the tutorial suggests
>
> from the Calalyst::Manual::Tutorial
> "First, create a directory to hold the class:
>
>     $ mkdir lib/MyAppDB
>
>
>
> so probably teaching newbs bad design isnt the best idea....
>
>
>

Even though the tutorial shows bad design, at least the DBIx docs get it
right :)
http://search.cpan.org/~blblack/Catalyst-Model-DBIC-Schema-0.18/lib/Catalys=
t/Model/DBIC/Schema.pm


By the way, when you say MyApp::Schema::Foo and MyApp::ResultSet::Foo  this
infers putting Schema and ResultSet dirs alongside the dirs "Controller",
"View", and "Model" in catalyst?


Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070522/6e7=
795dc/attachment.htm


More information about the Dbix-class mailing list