/[A3C]/lib/Strix.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/Strix.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 167 - (hide annotations)
Sun Jun 15 23:19:02 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 748 byte(s)
move Strix specific stuff to own package
1 dpavlin 167 package Strix;
2    
3     use strict;
4     use warnings;
5    
6     use base qw/Jifty::Object/;
7    
8     use DBI;
9     use Data::Dump qw/dump/;
10    
11     =head1 NAME
12    
13     Strix
14    
15     =head1 METHODS
16    
17     =head2 dbh
18    
19     my $dbh = Strix->dbh( $site_name );
20    
21     =cut
22    
23     sub dbh {
24     my $self = shift;
25    
26     my $site = shift or die "no site?";
27    
28     my $config = Jifty->config->app('strix') or die "need strix config";
29     my $database = $config->{database} or die "no strix.database in config";
30    
31     Jifty->log->debug("using config ", dump( $database ));
32    
33     my $dsn =
34     'DBI:Pg:dbname=' . $site .
35     ';host=' . $database->{host} .
36     ';port=' . $database->{port};
37    
38     Jifty->log->info("Connect to site $site with dsn $dsn");
39    
40     my $dbh = DBI->connect( $dsn, $database->{user}, $database->{passwd} ) or die $DBI::errstr;
41    
42     return $dbh;
43     }
44    
45     1;

  ViewVC Help
Powered by ViewVC 1.1.26