[Catalyst] How to use CDBI model outside Catalyst
Hartmaier Alexander
Alexander.Hartmaier at t-systems.at
Tue Dec 6 10:48:31 CET 2005
Or make your model classes, CDBI or DBIC, independent and just use them in
your Catalyst application(s).
Don't forget to add them in your Makefile.PL ;-)
-Alex
-----Original Message-----
From: catalyst-bounces at lists.rawmode.org
[mailto:catalyst-bounces at lists.rawmode.org] On Behalf Of apv
Sent: Tuesday, December 06, 2005 9:00 AM
To: Maxim Nechaev; The elegant MVC web framework
Subject: Re: [Catalyst] How to use CDBI model outside Catalyst
I just ran into this yesterday. I think you need to call your base app
class to do the initializations and get the tables and classes loaded.
use MyApp;
And then the "MyApp::NAMESPACE::Table->whatever()" will work.
I would actually prefer it if the CDBI class would do its own
initialization
if that's an idea that makes design sense.
-Ashley
On Monday, December 5, 2005, at 11:41 PM, Maxim Nechaev wrote:
> I have a Catalyst Application with CDBI model:
>
> ## MyApp/lib/MyApp/Model/CDBI.pm #################
> package MyApp::Model::CDBI;
> use base 'Catalyst::Model::CDBI';
> use strict;
> use warnings;
>
> __PACKAGE__->config
> (
> 'Class-DBI' =>
> {
> dsn => 'dbi:mysql:test',
> user => 'root',
> password => '',
> options => {},
> relationships => 0,
> },
> );
>
> 1;
> ##################################################
>
>
>
> Also I have a script outside Catalyst application in which i want use
> CDBI model. Now this script look like:
>
> ## MyApp/script/myapp_cron.pl ####################
> #!/usr/bin/perl -w
>
> use strict;
> use FindBin;
> use lib "$FindBin::Bin/../lib";
>
> use MyApp::Model::CDBI;
> ...
> ##################################################
>
> But it is not enough to start using MyApp::Model::CDBI::* classes.
> I think there need some additional initialization. But i can't find
> which.
> Can anybody help me?
> Thanks.
>
>
> --
> Maxim Nechaev
>
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>
>
_______________________________________________
Catalyst mailing list
Catalyst at lists.rawmode.org
http://lists.rawmode.org/mailman/listinfo/catalyst
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5544 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20051206/41d30a72/smime-0001.bin
More information about the Catalyst
mailing list