source: server/trunk/web/lib/Sophie/Base.pm @ 24

Last change on this file since 24 was 24, checked in by nanardon, 14 years ago
  • add make rpm target
File size: 755 bytes
Line 
1package Sophie::Base;
2
3use strict;
4use warnings;
5use DBI;
6use base qw/DBIx::Class::Schema/;
7use FindBin qw($Bin);
8
9__PACKAGE__->load_namespaces();
10
11sub connection {
12    my ($class) = @_;
13    $class->SUPER::connection(
14        sub { __PACKAGE__->db },
15   )
16}
17
18sub db {
19   my ($self) = @_;
20   require Config::General;
21   my $config;
22   foreach my $file ('sophie.conf', "$Bin/../sophie.conf") {
23       -f $file or next;
24        my $cg = Config::General->new($file);
25        $config = { $cg->getall() };
26    }
27    $config or die "No config found";
28
29   DBI->connect_cached(
30       'dbi:Pg:' . $config->{dbconnect},
31       $config->{dbuser},
32       $config->{dbpassword},
33       {
34           AutoCommit => 0,
35           PrintError => 1,
36       }
37   ); 
38}
39
40
41
421;
Note: See TracBrowser for help on using the repository browser.