OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Thomas Lotterer
  Root:   /v/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-registry                 Date:   03-Aug-2006 00:59:07
  Branch: HEAD                             Handle: 2006080223590600

  Modified files:
    openpkg-registry        registry-db.pl

  Log:
    improve code readability and remove term "workhorse" in anticipation
    to leverage new cfg file soon

  Summary:
    Revision    Changes     Path
    1.40        +26 -16     openpkg-registry/registry-db.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-registry/registry-db.pl
  ============================================================================
  $ cvs diff -u -r1.39 -r1.40 registry-db.pl
  --- openpkg-registry/registry-db.pl   2 Aug 2006 22:52:13 -0000       1.39
  +++ openpkg-registry/registry-db.pl   2 Aug 2006 22:59:06 -0000       1.40
  @@ -61,8 +61,8 @@
   $cfg->{db}->{registry}->{host}="127.0.0.1";
   $cfg->{db}->{registry}->{superuser}->{username}="postgresql";
   $cfg->{db}->{registry}->{superuser}->{password}="postgresql";
  -$cfg->{db}->{registry}->{workhorse}->{username}="registry";
  -$cfg->{db}->{registry}->{workhorse}->{password}="registry";
  +$cfg->{db}->{registry}->{username}="registry";
  +$cfg->{db}->{registry}->{password}="registry";
   $cfg->{db}->{registry}->{tablespace}="registry";
   $cfg->{db}->{session}->{dbfile}="$PREFIX/var/openpkg-registry/ui/session.db";
   
  @@ -76,17 +76,19 @@
   my $dbh; # database handle
   my $dbv; # database version
   
  -sub dbopen($) {
  +sub dbopen($)
  +{
       my ($db) = @_;
       my $dbi;
       $dbi = undef;
   
  -    print "==== processing Database $db ====\n";
       if    ($db eq "template1") {
  +        my $host     = $cfg->{db}->{registry}->{host};
  +        my $username = $cfg->{db}->{registry}->{superuser}->{username};
  +        my $password = $cfg->{db}->{registry}->{superuser}->{password};
  +        &debug("processing Database \"$db\" host=\"$host\", 
user=\"$username\", pass=\"$password\"");
           $dbi = DBI->connect (
  -            
"DBI:Pg:dbname=template1".";host=".$cfg->{db}->{registry}->{host},
  -            $cfg->{db}->{registry}->{superuser}->{username},
  -            $cfg->{db}->{registry}->{superuser}->{password},
  +            "DBI:Pg:dbname=template1".";host=$host", $username, $password,
               {
                   PrintError => 0,
                   PrintWarn  => 0,
  @@ -96,10 +98,13 @@
           );
       }
       elsif ($db eq "registry/superuser") {
  +        my $tablespace = $cfg->{db}->{registry}->{tablespace};
  +        my $host       = $cfg->{db}->{registry}->{host};
  +        my $username   = $cfg->{db}->{registry}->{superuser}->{username};
  +        my $password   = $cfg->{db}->{registry}->{superuser}->{password};
  +        &debug("processing Database \"$db\" tablespace=\"$tablespace\" 
host=\"$host\", user=\"$username\", pass=\"$password\"");
           $dbi = DBI->connect (
  -            
"DBI:Pg:dbname=".$cfg->{db}->{registry}->{tablespace}.";host=".$cfg->{db}->{registry}->{host},
  -            $cfg->{db}->{registry}->{superuser}->{username},
  -            $cfg->{db}->{registry}->{superuser}->{password},
  +            "DBI:Pg:dbname=$tablespace;host=$host", $username, $password,
               {
                   PrintError => 0,
                   PrintWarn  => 0,
  @@ -108,11 +113,14 @@
               }
           );
       }
  -    elsif ($db eq "registry/workhorse") {
  +    elsif ($db eq "registry") {
  +        my $tablespace = $cfg->{db}->{registry}->{tablespace};
  +        my $host       = $cfg->{db}->{registry}->{host};
  +        my $username   = $cfg->{db}->{registry}->{username};
  +        my $password   = $cfg->{db}->{registry}->{password};
  +        &debug("processing Database \"$db\" tablespace=\"$tablespace\" 
host=\"$host\", user=\"$username\", pass=\"$password\"");
           $dbi = DBI->connect (
  -            
"DBI:Pg:dbname=".$cfg->{db}->{registry}->{tablespace}.";host=".$cfg->{db}->{registry}->{host},
  -            $cfg->{db}->{registry}->{workhorse}->{username},
  -            $cfg->{db}->{registry}->{workhorse}->{password},
  +            "DBI:Pg:dbname=$tablespace;host=$host", $username, $password,
               {
                   PrintError => 0,
                   PrintWarn  => 0,
  @@ -122,8 +130,10 @@
           );
       }
       elsif ($db eq "session") {
  +        my $dbfile = $cfg->{db}->{session}->{dbfile};
  +        &debug("processing Database \"$db\" dbfile=\"$dbfile\"");
           $dbi = DBI->connect (
  -            "DBI:SQLite:dbname=".$cfg->{db}->{session}->{dbfile}, "", "",
  +            "DBI:SQLite:dbname=$dbfile", "", "",
               {
                   PrintError => 0,
                   PrintWarn  => 0,
  @@ -173,7 +183,7 @@
   
   #   registry
   #
  -$dbh = &dbopen("registry/workhorse");
  +$dbh = &dbopen("registry");
   die "ERROR:$0: DataBase error: ".$DBI::errstr."\n" if (not defined $dbh);
   while(&upgraderegistry()) {};
   $dbh->disconnect(); undef $dbh;
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     openpkg-cvs@openpkg.org

Reply via email to