Grokbase
x

Alex Kavanagh (a...@tinwood.homelinux.org)

Profile | Posts (6)

User Information

Display Name:Alex Kavanagh
Partial Email Address:a...@tinwood.homelinux.org
Posts:
6 total
1 in Catalyst Framework Development
1 in Catalyst Framework
4 in DBIx::Class

5 Most Recent

All Posts
1) Alex Kavanagh Re: [Catalyst] Problems using DBIx with update_or_create()
| +1 vote
Yes, I think so. It is the way that DBIx::Class is going. This framework is changing so rapidly...
Catalyst Framework
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
At Sat, 25 Feb 2006 10:16:04 -0700,
Nathan Kurz wrote:
>
> On Fri, Feb 24, 2006 at 07:01:07PM +0000, Matt S Trout wrote:
> > On Fri, Feb 24, 2006 at 10:22:11AM -0700, Nathan Kurz wrote:
> > > I'm having a small problem using Catalyst and the
> > > DBIx method update_or_create(). My code looks like this:
> > >
> > > my $user = Notate::Model::DB::User->update_or_create({
> > >        email => $email,
> > > password => md5_hex($password),
> > >     });
> > >
> > > When I run it, I get an exception that the object method
> > > 'update_or_create' could not be found. When I use 'create()',
> > > everything works as expected. I think this is just a small problem
> > > with ResultSetProxy.pm missing some functions. Or am I doing
> > > something fundamentally wrong?
> >
> > No, that's almost certainly the case. ResultSetProxy is designed to support
> > old usage until people convert over to the Schema approach. If you're still
> > using DB.pm you should be able to get at the schema object my calling
> >
> > One::Of::My::Classes->schema_instance
>
> Thanks! So for a new usage, I should be using DBIC::Schema instead of
> DBIC?

Yes, I think so.  It is the way that DBIx::Class is going.

> I hadn't known I was using an outdated approach, and certainly
> did not intend to. I went through the tutorial in the manual
> (supplemented with looking at the Parley as an example), and used what
> it gave me as a place to start from. From what I can tell, the
> tutorial (otherwise excellent) makes no mention of the new usage.

This framework is changing so rapidly that the docs don't keep up.
The only way I know what is going on is to keep an eye on this mailing
list.

>
> Do I still want to be using Authentication::Store::DBIC, or is there a
> corresponding Authentication::Store::DBIC::Schema that should be used
> instead? Or is DBIC:Schema compatible with DBIC once it's set up?

C::P::Authentication::Store::DBIC is compatible with Class::DBI, plain
DBIx::Class and DBIx::Class::Schema but only in the svn Trunk.  I
don't think that it has made it into a release yet (i.e. its 0.04 on
CPAN and 0.05 on svn trunk and only 0.05 has the DBIx::Class::Schema
support).

>
> And is there a canonical Catalyst DBIC::Schema example I should
> follow?

Not that I know of.  Anyone?

Cheers
Alex.


>
> Thanks!
>
> Nathan Kurz
> [email protected: n...@verse.com]
>
> _______________________________________________
> Catalyst mailing list
> [email protected: Cat...@lists.rawmode.org]
> http://lists.rawmode.org/mailman/listinfo/catalyst

_______________________________________________
Catalyst mailing list
[email protected: Cat...@lists.rawmode.org]
http://lists.rawmode.org/mailman/listinfo/catalyst
2) Alex Kavanagh [Catalyst-dev] Design Question brought about via work on C::P::A::S::DBIC
| +1 vote
Hi I've run into a fundamental design problem regarding some mods I was making to...
Catalyst Framework Development
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hi

I've run into a fundamental design problem regarding some mods I was
making to Catalyst::Plugin::Authentication::Storage::DBIC.

I've been modifying the code to support Catalyst::Model::DBIC::Schema
and after a bit of chat, concluded that using ->model was the best way
of getting the DBIx::Class object for the User table.

The problem can be stated:

What do I call ->model('Model::Table') on?

At the current stage I'm caching the $c when Backend.pm is created so
that User.pm has a instance on which ->model can be called.

However, this means that this instance of $c will be held for the
lifetime of the application and will be *different* to the $c that
request might be using to access the authentication modules.

An alternative, after discussing on #catalyst, was to cache the class
name of the application in Backend.pm so that ->model can be called on
that instead:

$class->model('Model::Table')

rather than

$first_instance->model('Model::Table')

So which is better, or is there an alternative way of doing this.

The *reason* I wanted to use ->model is that it works great for both
DBIx::Class and DBIx::Class::Schema models and makes the configuration
very simple: just set 'user_class' to 'SomeModel::SomeTable' and
->model( $user_class ) will either resolve to a DBIx::Class instance
or return a null.  If it's a null assume that 'user_class' is in the
form of 'AppName::SomeModel::SomeTable' and therefore it's Class::DBI
instead.

Any ideas?

Thanks
Alex (a.k.a tinwood on IRC).
3) Alex Kavanagh [Dbix-class] Catalyst::Model::DBIC::Schema
| +1 vote
Actually, this has been very helpful. The penny has now dropped - it allows the database to be...
DBIx::Class
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
At Wed, 8 Feb 2006 11:01:58 -0600,
Brandon Black wrote:
>
> On 2/8/06, Alex Kavanagh <alex@tinwood.homelinux.org> wrote:
> > Hi
> >
> > At Tue, 7 Feb 2006 21:24:44 -0600,
> > Brandon Black wrote:
> > >
> > > Catalyst::Model::DBIC::Schema exists now, although I haven't CPANed it
> > > yet, awaiting more feedback, it may still need some tweaks to its
> > > design.
> > >
> > > There's a snapshot available at
> > > http://www.dtmf.com/Catalyst-Model-DBIC-Schema-0.01.tar.gz
> >
> > I'm getting very lost with all of the database classes! Have you got
> > an example that uses:
> >
> > Catalyst
> > DBIx::Class::Schema
> > (and anything else relevant)
>
> For a quick rundown (I know this isn't everything...):

Actually, this has been very helpful.  The penny has now dropped - it
allows the database to be defined using DBIx::Class and be orthogonal
to Catalyst.  Very helpful!  Now I have to remove all of the
loaderism's from my proto-catalyst application and hook this in.

Thanks for your help.

Cheers
--
Alex.
4) Alex Kavanagh [Dbix-class] Catalyst::Model::DBIC::Schema
| +1 vote
Hi I'm getting very lost with all of the database classes! Have you got an example that uses:...
DBIx::Class
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hi

At Tue, 7 Feb 2006 21:24:44 -0600,
Brandon Black wrote:
>
> Catalyst::Model::DBIC::Schema exists now, although I haven't CPANed it
> yet, awaiting more feedback, it may still need some tweaks to its
> design.
>
> There's a snapshot available at
> http://www.dtmf.com/Catalyst-Model-DBIC-Schema-0.01.tar.gz

I'm getting very lost with all of the database classes!  Have you got
an example that uses:

Catalyst
DBIx::Class::Schema
(and anything else relevant)

Also, does this catalyst model use ::Schema::Loader ?

I think what I need, and could do with some help with, is some kind of
write up that explains what is going on with DBIx::Class,
DBIx::Class::Schema, whether classes are auto-generated and how
everything ties together.

e.g. What does Catalyst::Model::DBIC::Schema give you that
Catalyst::Model::DBIC doesn't and how does C::M::DBIC::Plain fit into
all of this?

It's all very confusing and really slowing down my Catalyst based web
site development at the moment.

Many thanks for any help you can give.

Cheers
Alex.
5) Alex Kavanagh [Dbix-class] DBIx::Class::Loader 0.18 released
| +1 vote
Okay, that's very useful and has definitely pointed me in the right direction. I think I've got a...
DBIx::Class
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
At Sat, 4 Feb 2006 15:03:56 -0600,
Brandon Black wrote:
>
> On 2/4/06, Brandon Black <blblack@gmail.com> wrote:
> > On 2/4/06, Alex Kavanagh <alex@tinwood.homelinux.org> wrote:
> > > Brandon Black wrote:
> > > > DBIx-Class-Schema-Loader is now at version 0.01002 on CPAN, and it
> > > > seems like it should work for most people. Please give it a shot.
> > > > The transition could be rough for some, as some Loader users are
> > > > probably using Loader-isms in their DBIx::Class code that will need to
> > > > be changed to Schema-isms. By 0.02 I expect it to be fairly stable,
> > > > other than future feature additions for obtaining better metadata and
> > > > building smarter relationships.
> > >
> > > Okay, I'd like to try to switch. I'm using it with Catalyst which
> > > I've only just started using and therefore I don't really know whether
> > > I'm using bad DBIx::Class usage habits.
> > >
> > > Is there a tutorial or some info on how to switch from D::C::L to
> > > D::C::S::L ??
> > >
> >
> > No, there's no such tutorial at this time, although perhaps there
> > should be a guide of sorts.
> >
> > The problem can really be divided into two parts. Firstly, even with
> > older versions of DBIx::Class and DBIx::Class::Loader, some people are
> > unwittingly using loader-specific methods and not realizing it. For
> > instance, I was using My::DB->table('foo_table')->search() all over
> > the place in my code. That usage of ->table('foo_table') is a
> > Loader-ism. Even at the time, converting off of ::Loader to a
> > manually-defined DBIx::Class would have meant eliminating that usage.
> >
> > Secondly, there's the differences between the old DB-based way of
> > using DBIx::Class, and the new Schema way. The old DB-way still works
> > for manual users of DBIx::Class, or users of DBIx::Class::Loader
> > against newer DBIx::Class, but I don't believe it quite works for
> > using ::Schema::Loader, seeing as the entire definition is done in the
> > Schema way, not the DB way.
> >
> > In the DB way, it was possible to do things like
> > My::DB::FooTable->search();
> >
> > Whereas in the Schema way, this should be written:
> > $myschema->resultset('foo_table')->search();
> >
> > Even in pre-0.05 DBIx::Class, the first method using statically
> > defined Table-class names was unwise, but it just worked. It still
> > works if your database and table classes are defined the DB-way, just
> > not if they're defined in the newer/better Schema way of doing things.
> > The new Schema::Loader defines them in the Schema way, so...
> >
> > Someone who was using DBIx::Class::Loader and then usage patterns like
> > MyDB->table('foo')->search()
> >
> > or
> > MyDB::Foo->search()
> >
> > will need to switch to:
> > $myschema->resultset('foo')->search()
> >
> > Technically you can also do:
> > My::Schema->resultset('foo')->search() on a connected schema-class,
> > but it's probably unwise as you'll have to go back and make them
> > object methods if you ever want to use multiple connections at the
> > same time within the same perl execution environment (for instance, if
> > this code is in a mod_perl app, and multiple instances of this app
> > with seperate databases are expected to run in a single apache
> > server).
> >
> > There are also loader-specific mechanisms in a Schema generated by
> > DBIx::Class::Schema::Loader, which should be avoided if you ever might
> > move off of Schema::Loader to manually defining your Schema. However,
> > it's rather difficult to not realize you're using them, as they are
> > all accessed via $myschema->loader, like $myschema->loader->tables;
> > $myschema->loader->monikers; etc.
> >
> > When/if you convert off od Schema::Loader, $myschema->loader is the
> > only thing that will cease to exist. Everything else should work the
> > same regardless of whether you're using ::Schema::Loader or a
> > manually-defined Schema.
> >
>
> That posting was a bit hasty, as the examples are poor. The usages
> shown of ->resultset() should look more like ->resultset('FooTable'),
> as the monikers tend to be uppercased in their first letters and not
> contain underscores.

Okay, that's very useful and has definitely pointed me in the right
direction. I think I've got a handle on how to use it manually.  Now
I've got to work out how to tie into in to Catalyst.  Time for a post
in the Catalyst mailing list I think.

Thanks
Alex.

spacer
Profile | Posts (6)
Home > People > Alex Kavanagh