[Catalyst] Accessing YAML details from within the Model libraries
John Napiorkowski
jjn1056 at yahoo.com
Thu Jan 18 14:37:16 GMT 2007
--- Anthony Gladdish <A.J.Gladdish at newcastle.ac.uk>
wrote:
> Hi,
>
> I'm trying to pull out all my DBIx::Class connection
> details for my
> Catalyst application, from a .yml config file,
> something like:
>
> ---
> model: MyCatPackage::Cat::Model::MyPackageDB
> schema_class: MyPackage::Schema
> connect_info:
> dsn: DBI:mysql:database=somedb;host=somehost
> username: user1
> password: password1
>
> Is it possible to access these details from the
> application's Model
> libraries? If so, what is the recommended way?
>
> I only seem to be able to access
> '__PACKAGE__->config->{schema_class}'
> (for example), via the catalyst application's main
> library, and NOT from
> within any of the Model libraries.
>
> Thanks,
>
> Anthony
I put all my config into into the .yml files for
models. My setup look like this:
'Model::myschemas':
schema_class: 'Schema::db'
connect_info:
- 'DBI:mysql:database=mydb;host=localhost'
- 'xxxxxxxxxx'
- 'xxxxxxxxxxx'
- RaiseError: 1
PrintError: 0
ShowErrorStatement: 1
TraceLevel: 0
I'm not sure about Models, but anything you put into a
controller is available via $self->{attr}
'Controller::test':
attr: onetwothree
then:
package myapp::Controller::test;
[snip snip]
sub myaction :Local {
my ($self, $c) = @_;
$c->log->info($self->{attr}); #onetwothree to log
}
I haven't tested this but I image it would work from
Views and Models as well. Give it a try.
--john
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
>
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
____________________________________________________________________________________
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
More information about the Catalyst
mailing list