[Catalyst] In search of a clue ... how do I access
_PACKAGE_->config values , or more specifically,
values put into myapp.yml ?
Matt S Trout
dbix-class at trout.me.uk
Mon Nov 5 21:37:44 GMT 2007
On Mon, Nov 05, 2007 at 12:37:27PM -0500, Joe Landman wrote:
> Hi folks:
>
> This should be an easy one. I read and read and read. The manual is
> fine, but my reading skills may be in doubt.
>
> This is what I want to do. I want to set a simple variable named
> myvar in myapp.yml. Then I want to pick it up later on.
>
> So far so good, I have
>
> myvar: blahblahblah
>
> in myapp.yml at the top of my application tree (in the same directory as
> lib, script, root, ...)
>
> Now, in one of my controllers, I want to get access myvar. I thought I
> can get at it like this:
>
> $c->config->{myvar}
Yep, that's exactly correct.
If it isn't there, your config is probably broken.
Though what I'd be more likely to do is
package MyApp::Controller::Foo;
__PACKAGE__->mk_accessors('myvar');
__PACKAGE__->config(myvar => 'default');
then in config
Controller::Foo:
myvar: 'not_the_default'
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list