From c6cb1f5a0ab5559e41eba001928e4a5ea595c051 Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Mon, 24 May 2004 12:49:58 +0000 Subject: [PATCH] * setprofileparam ==> setparam * serialization/deserialization of the profile file implemented (write-through semantics) * cloning of a profile fixed --- helm/uwobo/uwobo.ml | 17 ++++++++++++++--- helm/uwobo/uwobo_common.ml | 2 +- helm/uwobo/uwobo_profiles.ml | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/helm/uwobo/uwobo.ml b/helm/uwobo/uwobo.ml index b51169c9c..73cc23b65 100644 --- a/helm/uwobo/uwobo.ml +++ b/helm/uwobo/uwobo.ml @@ -35,13 +35,18 @@ let debug_level = `Notice ;; let debug_print s = if debug then prerr_endline s ;; Http_common.debug := false ;; +let configuration_file = "/projects/helm/etc/uwobo.conf.xml";; (* First of all we load the configuration *) let _ = - let configuration_file = "/projects/helm/etc/uwobo.conf.xml" in Helm_registry.load_from configuration_file ;; +let save_configuration () = + if not (Helm_registry.has "uwobo.cloned") then + Helm_registry.save_to configuration_file +;; + (* other settings *) let daemon_name = "UWOBO OCaml" ;; let default_media_type = "text/html" ;; @@ -254,7 +259,8 @@ let start_new_session cmd_pipe res_pipe outchan port logfile = let environment = (* Here I am loosing the current value of port_env_var; *) (* this should not matter *) - Unix.putenv "UWOBO__PORT" (string_of_int port) ; + Unix.putenv "uwobo__port" (string_of_int port) ; + Unix.putenv "uwobo__cloned" "1" ; Unix.environment () in (* 4. We exec a new copy of uwobo *) @@ -374,7 +380,7 @@ let callback (string_of_param_option req "password") in short_circuit_grandfather_and_client ~cmd ~cmd_pipe ~res_pipe outchan - | "/setprofileparam" -> + | "/setparam" -> let cmd = sprintf "setprofileparam %s,%s,%s,%s" (string_of_param_option req "id") (string_of_param_option req "password") @@ -650,6 +656,7 @@ let main () = ?password () in + save_configuration () ; output_string res_pipe ("Profile " ^ pid ^ " created. Hi " ^ pid) ; raise Restart_HTTP_daemon | _ -> assert false @@ -662,6 +669,7 @@ let main () = | _ -> assert false in Uwobo_profiles.remove pid ?password () ; + save_configuration () ; output_string res_pipe "Done" ; raise Restart_HTTP_daemon | line when Pcre.pmatch ~rex:setprofileparam_cmd_RE line -> (* /setprofileparam *) @@ -673,6 +681,7 @@ let main () = | _ -> assert false in Uwobo_profiles.set_param pid ?password ~key ~value () ; + save_configuration () ; output_string res_pipe "Done" ; raise Restart_HTTP_daemon | line when Pcre.pmatch ~rex:setpassword_cmd_RE line -> (* /setpassword *) @@ -684,6 +693,7 @@ let main () = | _ -> assert false in Uwobo_profiles.set_password pid ?old_password password ; + save_configuration () ; output_string res_pipe "Done" ; raise Restart_HTTP_daemon | line when Pcre.pmatch ~rex:setpermission_cmd_RE line -> (* /setpermission *) @@ -703,6 +713,7 @@ let main () = | _ -> assert false in Uwobo_profiles.set_permission pid ?password forwhat value ; + save_configuration () ; output_string res_pipe "Done" ; raise Restart_HTTP_daemon | cmd -> (* invalid interprocess command received *) diff --git a/helm/uwobo/uwobo_common.ml b/helm/uwobo/uwobo_common.ml index bdb455bc7..87a640b43 100644 --- a/helm/uwobo/uwobo_common.ml +++ b/helm/uwobo/uwobo_common.ml @@ -141,7 +141,7 @@ let usage_string = is set to false.

- setprofileparam?id=id[&password=password]&key=key[&value=value]
+ setparam?id=id[&password=password]&key=key[&value=value]
sets the property key to value, if value is provided; otherwise the parameter is unset. The password is required if the profile writing permission is set to false. diff --git a/helm/uwobo/uwobo_profiles.ml b/helm/uwobo/uwobo_profiles.ml index 715c24771..c34ba3ed9 100644 --- a/helm/uwobo/uwobo_profiles.ml +++ b/helm/uwobo/uwobo_profiles.ml @@ -111,7 +111,7 @@ let create ?id ?clone ?clone_password ?(read_perm=true) ?(write_perm=true) ?(adm check_permission pid clone_password `Read ; to_list_rel ~prefix:(params_key pid) () in - List.iter (fun (key, value) -> Helm_registry.set_string key value) params ; + List.iter (fun (key, value) -> Helm_registry.set_string (params_key pid ^ "." ^ key) value) params ; Helm_registry.set_bool (read_permission_key pid) read_perm ; Helm_registry.set_bool (write_permission_key pid) write_perm ; Helm_registry.set_bool (admin_permission_key pid) admin_perm ; -- 2.39.2