Permalink
Browse files

I am stupid...

  • Loading branch information...
phillipadsmith committed Aug 15, 2011
1 parent e5298c8 commit 0848df33ebb65cbe06836915c4cdc978c580a13e
Showing with 26 additions and 4 deletions.
  1. +26 −4 lib/Catalyst/Default/Model/DB.pm
@@ -2,14 +2,36 @@ package Catalyst::Default::Model::DB;
use strict;
use base 'Catalyst::Model::DBIC::Schema';
+use JSON;
+
+# Local development defaults
+
+my $db_user = 'catalyst';
+my $db_pass = 'catalyst';
+my $db_host = 'localhost';
+my $db_port = '5432';
+
+
+
+ # Override with the environment.json if it exists
+ # (This is not the best way to do this, but it works for the tutorial)
+ local $/;
+ open( my $fh, '<', '/home/dotcloud/environment.json' );
+ my $json = <$fh>;
+ if ( $json ) {
+ my $env = decode_json( $json );
+ $db_user = $env->{'DOTCLOUD_DATA_SQL_LOGIN'};
+ $db_pass = $env->{'DOTCLOUD_DATA_SQL_PASSWORD'};
+ $db_host = $env->{'DOTCLOUD_DATA_SQL_HOST'};
+ $db_port = $env->{'DOTCLOUD_DATA_SQL_PORT'};
+ }
__PACKAGE__->config(
schema_class => 'Catalyst::Default::Schema',
-
connect_info => {
- dsn => 'dbi:Pg:dbname=default-catalyst',
- user => 'catalyst',
- password => 'catalyst',
+ dsn => "dbi:Pg:dbname=default-catalyst;host=$db_host;port=$db_port",
+ user => $db_user,
+ password => $db_pass,
AutoCommit => q{1},
}
);

0 comments on commit 0848df3

Please sign in to comment.