Index: openacs.org-dev/packages/acs-tcl/tcl/parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/acs-tcl/tcl/parameter-procs.tcl,v diff -u -r1.1.1.2 -r1.1.1.3 --- openacs.org-dev/packages/acs-tcl/tcl/parameter-procs.tcl 5 Aug 2002 21:38:25 -0000 1.1.1.2 +++ openacs.org-dev/packages/acs-tcl/tcl/parameter-procs.tcl 8 Oct 2002 15:46:50 -0000 1.1.1.3 @@ -4,7 +4,7 @@ @author yon (yon@openforce.net) @creation-date May 12, 2002 - @version $Id$ + @cvs-id $Id$ } @@ -43,24 +43,41 @@ @param parameter which parameter's value to get @param default what to return if we don't find a value } { + if {[empty_string_p $package_id]} { ::set package_id [ad_requested_object_id] } - # 1. check to see if this parameter is being set in the server's - # configuration file; this value has highest precedence - ::set value [ad_parameter_from_file $parameter $package_id] + ::set package_key "" + ::set value "" + if {![empty_string_p $package_id]} { + # This can fail at server startup--OpenACS calls parameter::get to + # get the size of the util_memoize cache so it can setup the cache. + # apm_package_key_from_id needs that cache, but on server start + # when the toolkit tries to get the parameter for the cache size + # the cache doesn't exist yet, so apm_package_key_from_id fails + catch { + ::set package_key [apm_package_key_from_id $package_id] + } + } + # If I convert the package_id to a package_key, is there a parameter by this + # name in the parameter file? If so, it takes precedence. + # 1. use the parameter file + if {![empty_string_p $package_key]} { + ::set value [ad_parameter_from_file $parameter $package_key] + } + # 2. check the parameter cache if {[empty_string_p $value]} { - ::set value [ad_parameter_cache $package_id $parameter] - } - + ::set value [ad_parameter_cache $package_id $parameter] + } # 3. use the default value if {[empty_string_p $value]} { ::set value $default } + return $value } @@ -89,14 +106,22 @@ @param parameter which parameter's value to get @param default what to return if we don't find a value } { - with_catch errmsg { - ::set value [get \ - -package_id [apm_package_id_from_key $package_key] \ - -parameter $parameter \ - -default $default \ - ] - } { - ::set value $default + # 1. check to see if this parameter is being set in the server's + # configuration file; this value has highest precedence + ::set value [ad_parameter_from_file $parameter $package_key] + + # 2. try to get a package_id for this package_key and use the standard + # parameter::get function to get the value + if {[empty_string_p $value]} { + with_catch errmsg { + ::set value [get \ + -package_id [apm_package_id_from_key $package_key] \ + -parameter $parameter \ + -default $default \ + ] + } { + ::set value $default + } } return $value