]> git.donarmstrong.com Git - wannabuild.git/commitdiff
Add support for the public view of the data.
authorKurt Roeckx <kurt@roeckx.be>
Fri, 4 Sep 2009 18:56:12 +0000 (18:56 +0000)
committerKurt Roeckx <kurt@roeckx.be>
Fri, 4 Sep 2009 18:56:12 +0000 (18:56 +0000)
Currently does this for user nobody, to be able to use from the website.
We probably want to make this decission some other way.

bin/wanna-build

index 5b6fd6784b3ed1a748b5f189dad5a8eebe918a3e..070009fecb760a32822f775de4c1b34d76be5b5a 100755 (executable)
@@ -301,8 +301,18 @@ END {
        }
 }
 
-$dbh = DBI->connect("DBI:Pg:database=wanna-build") || 
-       die "FATAL: Cannot open database: $DBI::errstr\n";
+my $schema_suffix = '';
+# TODO: Base this on something else, like an option that is passed.
+if ($real_user eq 'nobody') {
+       $dbh = DBI->connect("DBI:Pg:service=wanna-build") || 
+               die "FATAL: Cannot open database: $DBI::errstr\n";
+       $schema_suffix = '_public';
+}
+else
+{
+       $dbh = DBI->connect("DBI:Pg:service=wanna-build-privileged") || 
+               die "FATAL: Cannot open database: $DBI::errstr\n";
+}
 
 # TODO: This shouldn't be needed, file a bug.
 $dbh->{pg_server_prepare} = 0;
@@ -2374,11 +2384,11 @@ sub pkg_version_eq {
 }
 
 sub table_name {
-       return '"' . $arch . '".packages';
+       return '"' . $arch . $schema_suffix . '".packages';
 }
 
 sub user_table_name {
-       return '"' . $arch . '".users';
+       return '"' . $arch . $schema_suffix . '".users';
 }
 
 sub get_source_info {