koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Context.pm,1.14,1.15


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Context.pm,1.14,1.15
Date: Fri, 13 Aug 2004 02:13:17 -0700

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17702/C4

Modified Files:
        Context.pm 
Log Message:
patch from A. Tarallo (for differents DB schemes)

Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** Context.pm  5 Jun 2003 17:03:32 -0000       1.14
--- Context.pm  13 Aug 2004 09:13:14 -0000      1.15
***************
*** 17,20 ****
--- 17,23 ----
  
  # $Id$
+ # Revision History:
+ # 2004-08-11 A. Tarallo: Added the function db_escheme2dbi, tested my 
bugfixes,
+ # further  details about them in the code.
  
  package C4::Context;
***************
*** 101,104 ****
--- 104,117 ----
  # configuration values (duh).
  # Returns undef in case of error.
+ #
+ # Revision History:
+ # 2004-08-10 A. Tarallo: Added code that checks if a variable was already
+ # assigned and prints a message, otherwise create a new entry in the hash to
+ # be returned. 
+ # Also added code that complaints if finds a line that isn't a variable 
+ # assignmet and skips the line.
+ # Added a quick hack that makes the trasnlation between the db_schema
+ # and the DBI driver for that eschema.
+ #
  sub read_config_file
  {
***************
*** 122,135 ****
                if (!/^\s*(\w+)\s*=\s*(.*?)\s*$/)
                {
!                       # FIXME - Complain about bogus line
                        next;
                }
  
                # Found a variable assignment
!               # FIXME - Ought to complain is this line sets a
!               # variable that was already set.
!               $var = $1;
!               $value = $2;
!               $retval->{$var} = $value;
        }
        close CONF;
--- 135,158 ----
                if (!/^\s*(\w+)\s*=\s*(.*?)\s*$/)
                {
!                       print STDERR 
!                               "$_ isn't a variable assignment, skipping it";
                        next;
                }
  
                # Found a variable assignment
!               if ( exists $retval->{$1} )
!               {
!                       print STDERR "$var was already defined, ignoring\n";
!               }else{
!               # Quick hack for allowing databases name in full text
!                       if ( $1 eq "db_scheme" )
!                       {
!                               $value = db_scheme2dbi($2);
!                       }else {
!                               $value = $2;
!                       }
!                       $var = $1;
!                         $retval->{$var} = $value;
!               }
        }
        close CONF;
***************
*** 138,141 ****
--- 161,179 ----
  }
  
+ # db_scheme2dbi
+ # Translates the full text name of a database into de appropiate dbi name
+ # 
+ sub db_scheme2dbi
+ {
+       my $name = shift;
+ 
+       for ($name) {
+               if (/MySQL|mysql/) { return("mysql"); }
+               if (/Postgres|Pg|PostgresSQL/) { return("Pg"); }
+               if (/Oracle|oracle|ORACLE/) { return("Oracle"); }
+       }
+       return undef;           # Just in case
+ }
+ 
  sub import
  {
***************
*** 165,168 ****
--- 203,208 ----
  =cut
  #'
+ # Revision History:
+ # 2004-08-10 A. Tarallo: Added check if the conf file is not empty
  sub new
  {
***************
*** 171,176 ****
        my $self = {};
  
!       # check that the specified config file exists
!       undef $conf_fname unless (defined $conf_fname && -e $conf_fname);
        # Figure out a good config file to load if none was specified.
        if (!defined($conf_fname))
--- 211,217 ----
        my $self = {};
  
!       # check that the specified config file exists and is not empty
!       undef $conf_fname unless 
!               (defined $conf_fname && -e $conf_fname && -s $conf_fname);
        # Figure out a good config file to load if none was specified.
        if (!defined($conf_fname))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]