Ta, for the pointers. This does it, if anyone else has similar needs In your conf.yml global_config : "../shared_conf/config.yml" # with relation to appdir and some code to load it: sub includeGlobalConfig { my $self = shift; my ($appdir) = setting('appdir'); # For some reason Mason2 does not like the relative path $appdir =~ s|/bin/..||; my ($gconfig_file) = $appdir . "/" . config->{global_config}; die "Unable to find global config '$gconfig_file'" unless -f $gconfig_file; my ($gconfig) = YAML::LoadFile($gconfig_file); # Merge with default map { config->{$_} = $gconfig->{$_} } keys %{$gconfig}; # If your using Mason2 config->{engines}{mason2}->{data_dir} = $appdir . "/data"; config->{engines}{mason2}->{comp_root} = $appdir . "/views"; config->{engines}{mason2}->{autoextend_request_path} = 0; # Mason2 bug - when not running from server (i.e. test), it looses appdir for views config->{views} = $appdir . "/views"; }; And call it in your app.pm - something like: package MyApp; use Dancer ':syntax'; MyApp::Config->new()->includeGlobalConfig(); get '/index' => { ...... }; On 15 November 2011 10:45, Stephen Fenwick-Paul <stephen@activeg.org> wrote:
Thanks, that's the way I will go.
On 15 November 2011 10:44, David Precious <davidp@preshweb.co.uk> wrote:
On Tuesday 15 November 2011 10:42:21 David Precious wrote:
In the meantime, you could store your database settings in a separate YAML file, then in your apps, load that and put it into the app's config with something a little like:
my $db_conf = YAML::LoadFile('database.yml'); config->{plugins}{Database} = $db_conf;
That should work :)
And of course that could be even more concise using the from_yaml() keyword provided by Dancer, e.g.:
config->{plugins}{Database} = from_yaml('database.yml');
-- David Precious ("bigpresh") http://www.preshweb.co.uk/
"Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
participants (1)
-
Stephen Fenwick-Paul