[Maypole-dev] config parameter handling for Maypole::Model::CDBI

From: Sebastian Riedel (sri at oook.de)
Date: Wed Sep 08 2004 - 19:06:17 BST


Hi,

Today i've added config parameter handling to setup_database() in
Maypole::Model::CDBI to make it possible to do this:

package MyApp;

use strict;
use base qw(Maypole::Application Maypole::Config::YAML);

MyApp->load_config;
MyApp->setup;

1;
__DATA__
--- #YAML:1.0
dsn: 'dbi:Pg:dbname=myapp'
user: myuser
pass: mypass
uri_base: 'http://127.0.0.1/myapp'
template_root: '/home/sri/myapp/templates'
rows_per_page: 10

Index: lib/Maypole/Model/CDBI.pm
===================================================================
--- lib/Maypole/Model/CDBI.pm (revision 166)
+++ lib/Maypole/Model/CDBI.pm (working copy)
@@ -132,6 +132,10 @@
 
 sub setup_database {
     my ($self, $config, $namespace, $dsn, $u, $p, $opts) = @_;
+ $dsn ||= $config->{dsn};
+ $u ||= $config->{user};
+ $p ||= $config->{pass};
+ $opts ||= $config->{opts};
     $config->{dsn} = $dsn;
     $config->{loader} = Class::DBI::Loader->new(
         namespace => $namespace,

_______________________________________________
maypole-dev mailing list
maypole-dev at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole-dev



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT