Changeset 61


Ignore:
Timestamp:
Apr 24, 2003, 6:05:34 PM (19 years ago)
Author:
kake
Message:

Finished adding mysql support - no sqlite support yet as it's a bit messier

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Build.PL

    r60 r61  
    8383my @answers;
    8484
    85 # Database type is speshull - can be one of three.
     85# Database type is speshull - can be one of two.
    8686my $dbtype;
    87 my $dbtype_qu = "what type of database do you want the site to run on?  postgres/mysql/sqlite";
     87my $dbtype_qu = "what type of database do you want the site to run on?  postgres/mysql";
    8888if ( $skip_config ) {
    8989    $dbtype = $existing_config{dbtype} || "postgres";
     
    9595        $dbtype =~ s/^\s*//;
    9696        $dbtype =~ s/\s*$//;
    97         unless ( $dbtype eq "postgres" or $dbtype eq "mysql"
    98                  or $dbtype eq "sqlite" ) {
     97        unless ( $dbtype eq "postgres" or $dbtype eq "mysql" ) {
    9998            undef $dbtype;
    10099        }
    101100    }
    102101}
     102
     103# Check they have the relevant DBD driver installed.
     104my %drivers = ( postgres => "DBD::Pg",
     105                mysql    => "DBD:mysql" );
     106eval "require $drivers{$dbtype}";
     107die "$drivers{$dbtype} is needed to run a $dbtype database" if $@;
     108
    103109push @answers, { question => $dbtype_qu,
    104110                 variable => "dbtype",
     
    189195        'Config::Tiny' => 0,
    190196        'Data::Dumper' => 0,
     197        $drivers{$dbtype} => 0,
    191198        'File::Spec::Functions' => 0,
    192199        'Geography::NationalGrid' => 0,
  • trunk/lib/OpenGuides/Build.pm

    r60 r61  
    1212    die "Config::Tiny is required to set up this application.\n" if $@;
    1313
    14     eval "use CGI::Wiki::Setup::Pg";
    15     die "CGI::Wiki is required to set up this application.\n" if $@;
    16 
    1714    my $config = Config::Tiny->read("wiki.conf");
    1815    my $dbname = $config->{_}->{dbname};
     
    2017    my $dbpass = $config->{_}->{dbpass};
    2118    my $dbhost = $config->{_}->{dbhost};
     19    my $dbtype = $config->{_}->{dbtype};
     20
     21    my %cgi_wiki_exts = ( postgres => "Pg",
     22                          mysql    => "MySQL" );
     23
     24    my $cgi_wiki_module = "CGI::Wiki::Setup::" . $cgi_wiki_exts{$dbtype};
     25    eval "require $cgi_wiki_module";
     26    die "CGI::Wiki is required to set up this application.\n" if $@;
    2227
    2328    print "Checking database schema...\n";
    24     CGI::Wiki::Setup::Pg::setup( $dbname, $dbuser, $dbpass, $dbhost );
     29    {
     30        no strict 'refs';
     31        &{$cgi_wiki_module . "::setup"}( $dbname, $dbuser, $dbpass, $dbhost );
     32    }
    2533}
    2634
  • trunk/wiki.cgi

    r60 r61  
    1313use CGI::Cookie;
    1414use CGI::Wiki;
    15 use CGI::Wiki::Store::Pg;
    1615use CGI::Wiki::Search::SII;
    1716use CGI::Wiki::Formatter::UseMod;
     
    4443my $template_path = $config->{_}->{template_path};
    4544
     45# Require in the right database module.
     46my $dbtype = $config->{_}->{dbtype};
     47
     48my %cgi_wiki_exts = ( postgres => "Pg",
     49                      mysql    => "MySQL" );
     50
     51my $cgi_wiki_module = "CGI::Wiki::Store::" . $cgi_wiki_exts{$dbtype};
     52eval "require $cgi_wiki_module";
     53die "Can't 'require' $cgi_wiki_module.\n" if $@;
     54
    4655# Make store.
    47 my $store = CGI::Wiki::Store::Pg->new(
     56my $store = $cgi_wiki_module->new(
    4857    dbname => $config->{_}{dbname},
    4958    dbuser => $config->{_}{dbuser},
Note: See TracChangeset for help on using the changeset viewer.