Index: openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql 22 Mar 2010 01:58:08 -0000 1.16 +++ openacs-4/packages/acs-tcl/tcl/apm-procs-oracle.xql 25 Mar 2010 01:02:16 -0000 1.17 @@ -62,6 +62,13 @@ + + + begin + apm.unregister_parameter(:parameter_id); + end; + + Index: openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql,v diff -u -r1.17 -r1.18 --- openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 22 Mar 2010 01:58:08 -0000 1.17 +++ openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 25 Mar 2010 01:02:16 -0000 1.18 @@ -56,6 +56,12 @@ + + + select apm__unregister_parameter(:parameter_id) + + + @@ -142,24 +148,6 @@ - - - - - begin - delete from apm_parameter_values - where parameter_id = :parameter_id; - delete from apm_parameters - where parameter_id = :parameter_id; - PERFORM acs_object__delete(:parameter_id); - - return null; - end; - - - - - Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v diff -u -r1.85 -r1.86 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 22 Mar 2010 01:58:08 -0000 1.85 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 25 Mar 2010 01:02:16 -0000 1.86 @@ -1017,36 +1017,21 @@ Unregisters a parameter from the system. } { if { $parameter_id eq "" } { - set parameter_id [db_string select_parameter_id { - select parameter_id - from apm_parameters - where package_key = :package_key - and parameter_name = :parameter - }] + set parameter_id [db_string select_parameter_id {}] } + db_1row get_scope_and_name {} + ns_log Debug "apm_parameter_unregister: Unregistering parameter $parameter_id." - db_foreach all_parameters_packages { - select package_id, parameter_id, parameter_name - from apm_packages p, apm_parameters ap - where p.package_key = ap.package_key - and ap.parameter_id = :parameter_id - } { - ad_parameter_cache -delete $package_id $parameter_name - } if_no_rows { - return + if { $scope eq "global" } { + ad_parameter_cache -delete $package_key $parameter_name + } else { + db_foreach all_parameters_packages {} { + ad_parameter_cache -delete $package_id $parameter_name + } } - - db_exec_plsql parameter_unregister { - begin - delete from apm_parameter_values - where parameter_id = :parameter_id; - delete from apm_parameters - where parameter_id = :parameter_id; - acs_object.del(:parameter_id); - end; - } + db_exec_plsql unregister {} } ad_proc -public apm_dependency_add { Index: openacs-4/packages/acs-tcl/tcl/apm-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.xql,v diff -u -r1.26 -r1.27 --- openacs-4/packages/acs-tcl/tcl/apm-procs.xql 10 Mar 2010 00:44:03 -0000 1.26 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.xql 25 Mar 2010 01:02:16 -0000 1.27 @@ -172,6 +172,23 @@ + + + select parameter_id + from apm_parameters + where package_key = :package_key + and parameter_name = :parameter + + + + + + select scope, parameter_name + from apm_parameters + where parameter_id = :parameter_id + + + select package_id, parameter_id, parameter_name Index: openacs-4/packages/acs-tcl/tcl/defs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/defs-procs.tcl,v diff -u -r1.59 -r1.60 --- openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 12 Feb 2009 15:38:41 -0000 1.59 +++ openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 25 Mar 2010 01:02:16 -0000 1.60 @@ -683,42 +683,39 @@ ad_proc -private ad_parameter_cache { -set -delete:boolean - package_id + -global:boolean + key parameter_name } { Manages the cache for ad_paremeter. @param -set Use this flag to indicate a value to set in the cache. - @param package_id Specifies the package instance id for the parameter. + @param -delete Delete the value from the cache + @param -global If true, global param, false, instance param + @param key Specifies the key for the cache'd parameter, either the package instance + id (instance parameter) or package key (global parameter). @param parameter_name Specifies the parameter name that is being cached. @return The cached value. } { if {$delete_p} { - if {[nsv_exists ad_param_$package_id $parameter_name]} { - nsv_unset ad_param_$package_id $parameter_name + if {[nsv_exists ad_param_$key $parameter_name]} { + nsv_unset ad_param_$key $parameter_name } return } if {[info exists set]} { - nsv_set "ad_param_${package_id}" $parameter_name $set + nsv_set "ad_param_${key}" $parameter_name $set return $set - } elseif { [nsv_exists ad_param_$package_id $parameter_name] } { - return [nsv_get ad_param_$package_id $parameter_name] + } elseif { [nsv_exists ad_param_$key $parameter_name] } { + return [nsv_get ad_param_$key $parameter_name] + } elseif { $global_p } { + set value [db_string select_global_parameter_value {} -default ""] } else { - set value [db_string select_parameter_value { - select apm_parameter_values.attr_value - from apm_parameters, - apm_parameter_values - where apm_parameter_values.package_id = :package_id - and apm_parameter_values.parameter_id = apm_parameters.parameter_id - and apm_parameters.parameter_name = :parameter_name - } -default ""] - - nsv_set "ad_param_${package_id}" $parameter_name $value - - return $value + set value [db_string select_instance_parameter_value {} -default ""] } + nsv_set "ad_param_${key}" $parameter_name $value + return $value } ad_proc -private ad_parameter_cache_all {} { Index: openacs-4/packages/acs-tcl/tcl/defs-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/defs-procs.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-tcl/tcl/defs-procs.xql 30 Nov 2002 17:23:55 -0000 1.2 +++ openacs-4/packages/acs-tcl/tcl/defs-procs.xql 25 Mar 2010 01:02:16 -0000 1.3 @@ -10,16 +10,26 @@ - + select apm_parameter_values.attr_value from apm_parameters, apm_parameter_values - where apm_parameter_values.package_id = :package_id + where apm_parameter_values.package_id is null and apm_parameter_values.parameter_id = apm_parameters.parameter_id and apm_parameters.parameter_name = :parameter_name + + + select apm_parameter_values.attr_value + from apm_parameters, apm_parameter_values + where apm_parameter_values.package_id = :key + and apm_parameter_values.parameter_id = apm_parameters.parameter_id + and apm_parameters.parameter_name = :parameter_name + + + select v.package_id, p.parameter_name, v.attr_value Index: openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 10 Mar 2010 00:44:03 -0000 1.17 +++ openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 25 Mar 2010 01:02:16 -0000 1.18 @@ -43,7 +43,7 @@ db_exec_plsql set_parameter_value {} - return [ad_parameter_cache -set $value $package_id $parameter] + return [ad_parameter_cache -set $value $package_key $parameter] } ad_proc -public parameter::get_global_value { @@ -73,7 +73,7 @@ # 2. check the parameter cache if {$value eq ""} { - set value [ad_parameter_cache $package_id $parameter] + set value [ad_parameter_cache -global $package_key $parameter] } # 3. use the default value if {$value eq ""} { Index: openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl 17 Aug 2006 08:43:17 -0000 1.2 +++ openacs-4/packages/acs-tcl/tcl/test/apm-parameter-test-procs.tcl 25 Mar 2010 01:02:16 -0000 1.3 @@ -13,25 +13,19 @@ set package_key "acs-tcl" set default_value "5" set datatype "number" - aa_log "Registering a parameter" - apm_parameter_register -parameter_id $parameter_id $parameter_name $description $package_key $default_value $datatype + set scope "instance" + aa_log "Registering an instance parameter" + apm_parameter_register -parameter_id $parameter_id -scope $scope $parameter_name $description $package_key $default_value $datatype set package_id [apm_package_id_from_key $package_key] - aa_true "check apm_parameter_register" [string equal [parameter::get -package_id $package_id -parameter $parameter_name] $default_value] -} + aa_true "check apm_parameter_register instance parameter" [string equal [parameter::get -package_id $package_id -parameter $parameter_name] $default_value] + aa_log "Unregistering an instance parameter" + apm_parameter_unregister $parameter_id -aa_register_case -cats {api smoke} parameter_unregister_test { - Test the unregister of a parameter -} { - set parameter_id [db_nextval "acs_object_id_seq"] - set parameter_name [ad_generate_random_string] - set description "Description for the new parameter" - set package_key "acs-tcl" - set default_value "10" - set datatype "number" - aa_log "Registering a parameter" - apm_parameter_register -parameter_id $parameter_id $parameter_name $description $package_key $default_value $datatype + set scope "global" + aa_log "Registering a global parameter" + apm_parameter_register -parameter_id $parameter_id -scope $scope $parameter_name $description $package_key $default_value $datatype + aa_true "check apm_parameter_register global parameter" [string equal [parameter::get_global_value -package_key $package_key -parameter $parameter_name] $default_value] + aa_log "Unregistering an global parameter" apm_parameter_unregister $parameter_id - set package_id [apm_package_id_from_key $package_key] - aa_true "check apm_parameter_unregister" [string equal [parameter::get -package_id $package_id -parameter $parameter_name] ""] }