X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Flib%2Fcocanwiki_server_settings.ml;h=6f8e25968ad6a7c36441845e602cf0c94e2c4de4;hb=d303f75eed3a09bbe2516d9a2a9a4aa9b862ceb3;hp=40a7ad80d50cc5f3382daa55e517995858fdc239;hpb=20923b33c08fccfca617b21935c4a4f6201593f8;p=cocanwiki.git diff --git a/scripts/lib/cocanwiki_server_settings.ml b/scripts/lib/cocanwiki_server_settings.ml index 40a7ad8..6f8e259 100644 --- a/scripts/lib/cocanwiki_server_settings.ml +++ b/scripts/lib/cocanwiki_server_settings.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_server_settings.ml,v 1.1 2004/10/21 11:42:05 rich Exp $ + * $Id: cocanwiki_server_settings.ml,v 1.2 2006/03/27 16:43:44 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,26 +37,16 @@ open Printf *) let server_settings_version, server_settings_stats_page, server_settings_crash_email = - let default = 1, None, None in + let default = 1l, None, None in let settings = ref None in - let get_settings (dbh : Dbi.connection) = - let sth = dbh#prepare "select version, stats_page, crash_email - from server_settings" in - sth#execute []; + let get_settings dbh = + let rows = PGSQL(dbh) + "select version, stats_page, crash_email from server_settings" in let s = - try - (match sth#fetch1 () with - | [ `Int version; (`String _ | `Null) as stats_page; - (`String _ | `Null) as crash_email ] -> - let stats_page = - match stats_page with `String s -> Some s | `Null -> None in - let crash_email = - match crash_email with `String s -> Some s | `Null -> None in - version, stats_page, crash_email - | _ -> assert false) - with - Not_found -> default in - sth#finish (); + match rows with + | [row] -> row + | [] -> default + | _ -> assert false in settings := Some s; s in @@ -64,24 +54,24 @@ let server_settings_version, server_settings_stats_page, let server_settings_version dbh = let (version, _, _) = match !settings with - None -> get_settings dbh - | Some settings -> settings in + | None -> get_settings dbh + | Some settings -> settings in version in let server_settings_stats_page dbh = let (_, stats_page, _) = match !settings with - None -> get_settings dbh - | Some settings -> settings in + | None -> get_settings dbh + | Some settings -> settings in stats_page in let server_settings_crash_email dbh = let (_, _, crash_email) = match !settings with - None -> get_settings dbh - | Some settings -> settings in + | None -> get_settings dbh + | Some settings -> settings in crash_email in