[Catalyst] Catalys & TheSchwartz, was Catalyst modperl - child process segmentation fault

Rodrigo rodrigolive at gmail.com
Thu Jan 8 18:07:37 GMT 2009


This is what I'm using for creating TheSchwartz::Moosified connections from
Catalyst:

use TheSchwartz::Moosified;
my $client =3D TheSchwartz::Moosified->new();
#  this will get you a dbh with DBIx::Class::Storage::DBI exception
handling:
MyCatalystApp->model('MyModel')->storage->dbh_do(
    sub {
        my ($storage, $dbh) =3D @_;
        $client->databases([$dbh]) or die $!;
    }
);
# this also works:
#  $client->databases([MyCatalystApp->model('MyModel')->storage->dbh]);

$client->insert( ... );

The advantage is that you won't have to create a new dbh connection
everytime you insert a job, in case that's what you want.

The disadvantage is that I don't know how far the moosified version is
backward compatible with the original TheSchwartz (it has worked fine for me
so far).

cheers,
  rodrigo

On Thu, Jan 8, 2009 at 5:42 PM, J. Shirley <jshirley at gmail.com> wrote:

> On Thu, Jan 8, 2009 at 3:39 AM, Matija Grabnar <matija at serverflow.com>
> wrote:
> >> afaict, you should let dbic / cat-model handle the connection to the
> >> database.
> >
> > That reminds me. Does anybody have experience submitting TheSchwartz jo=
bs
> > from a Catalyst?
> >
> > TheSchwartz uses it's own system of allocating DB handles, and I have no
> > idea how it interacts with
> > Catalyst's.
> >
> > I *think* I'm safe because I'm not allocating any schwatz connections
> until
> > I'm actually serving a
> > Catalyst request, but I'd like to hear from anybody who has actual
> > experience...
> >
>
> I've done quite a bit of work with TheSchwartz and Catalyst.
>
> Catalyst does -nothing- with database handles.  Absolutely nothing.
> If you use a database, chances are you are using
> Catalyst::Model::DBIC::Schema which then uses DBIx::Class.
>
> TheSchwartz uses Data::ObjectDriver for its ORM.  The two play just
> fine together.
>
> The model class for TheSchwartz is quite simple:
>
> package MyApp::Model::TheSchwartz;
>
> use base 'Catalyst::Model';
>
> use TheSchwartz;
>
> sub COMPONENT {
>        return TheSchwartz->new( databases =3D> $DATABASE_INFO );
> }
>
> 1;
>
> >From there, you can just do $c->model("TheSchwartz")->insert(...); and
> the job will be inserted.  Look at the pod for TheSchwartz for the
> database info, and the schema for TheSchwartz database is hidden away
> in the distribution with no links:
> http://search.cpan.org/src/BRADFITZ/TheSchwartz-1.07/doc/
>
> TheSchwartz also fails tests so you have to force install, has
> terrible documentation and is generally frustrating to use because of
> these superficial shortcomings.
>
> The code itself is sound enough, but the packaging and release is
> quite terrible.  It will take you some time to sort it out and get
> everything running, so good luck.  Once it is up and running, it is
> quite simple and the API is good.
>
>
> -J
>
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090108/9da53=
9e4/attachment.htm


More information about the Catalyst mailing list