From 4b3d3bb2653b9332b485b502a149efcc50ddbe94 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sun, 29 Mar 2009 11:17:29 +0000 Subject: [PATCH] =?utf8?q?Modell-Konfiguration=20auf=20native=20Konfigurat?= =?utf8?q?ion=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- frbr_books.yml | 18 ++++++++++++------ lib/FrBr/Books/Model/Schema.pm | 8 ++++---- lib/FrBr/Books/Plugin/ConfigLoader.pm | 20 -------------------- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/frbr_books.yml b/frbr_books.yml index bbac7a1..0ad7f6a 100644 --- a/frbr_books.yml +++ b/frbr_books.yml @@ -17,12 +17,18 @@ default_list_length: 20 # Sitzungsparameter session: expires: 7200 -database: - host: localhost - port: 3306 - schema: books - user: books - # passwd: +# +# Direkte Modell-Konfiguration: +'Model::Schema': + schema_class: 'FrBr::Books::Db' + connect_info: + - 'DBI:mysql:database=books;host=localhost' + - 'books' + - ~ + - AutoCommit: 1 + PrintError: 0 + RaiseError: 0 +# authentication: dbic: # Note this first definition would be the same as setting diff --git a/lib/FrBr/Books/Model/Schema.pm b/lib/FrBr/Books/Model/Schema.pm index 4de7279..b738794 100644 --- a/lib/FrBr/Books/Model/Schema.pm +++ b/lib/FrBr/Books/Model/Schema.pm @@ -7,11 +7,11 @@ use strict; use base 'Catalyst::Model::DBIC::Schema'; __PACKAGE__->config( - schema_class => 'FrBr::Books::Db', + 'schema_class' => 'FrBr::Books::Db', 'connect_info' => [ - $ENV{'FRBR_BOOKS_DSN'} || 'dbi:mysql:database=books;host=localhost', - $ENV{'FRBR_BOOKS_USER'} || 'books', - $ENV{'FRBR_BOOKS_PWD'} || '', + 'dbi:mysql:database=books;host=localhost', + 'books', + '', { 'AutoCommit' => 1, 'PrintError' => 0, 'RaiseError' => 0, diff --git a/lib/FrBr/Books/Plugin/ConfigLoader.pm b/lib/FrBr/Books/Plugin/ConfigLoader.pm index 2247463..92efcfd 100644 --- a/lib/FrBr/Books/Plugin/ConfigLoader.pm +++ b/lib/FrBr/Books/Plugin/ConfigLoader.pm @@ -70,26 +70,6 @@ sub finalize_config { $c->log->debug( $K . "Log4perl-Konfiguration:\n" . $log4perlconf ) if $c->config->{'debug_level'} >= 1; $c->log( Catalyst::Log::Log4perl->new( \$log4perlconf ) ); - my $dsn = 'dbi:mysql:host=%s;database=%s'; - - $dsn = sprintf( $dsn, ( $c->config()->{'database'}->{'host'} || 'localhost' ), - ( $c->config()->{'database'}->{'schema'} || 'books' ) ); - - my $port = 3306; - if ( $c->config()->{'database'}->{'port'} and to_int( $c->config()->{'database'}->{'port'} ) ) { - $port = $c->config()->{'database'}->{'port'}; - } - $port = $port == 3306 ? '' : ';port=' . $port; - $dsn .= $port; - - $c->config()->{'dsn'} = $dsn; - $c->config()->{'db_user'} = $c->config()->{'database'}->{'user'} || 'cookbook'; - $c->config()->{'db_passwd'} = $c->config()->{'database'}->{'passwd'} || ''; - - $ENV{'FRBR_BOOKS_DSN'} = $dsn; - $ENV{'FRBR_BOOKS_USER'} = $c->config()->{'db_user'}; - $ENV{'FRBR_BOOKS_PWD'} = $c->config()->{'db_passwd'}; - $c->log->debug( get_output_string( $K, "Aktuelle Konfiguration: ", $c->config ) ) if $c->config->{'debug_level'} >= 3; } ## end sub finalize_config -- 2.39.5