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.26.2.6 -r1.26.2.7 --- openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 27 Oct 2021 16:46:37 -0000 1.26.2.6 +++ openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 21 Feb 2022 20:13:43 -0000 1.26.2.7 @@ -208,68 +208,84 @@ -value $value } -ad_proc -public parameter::get_from_package_key { - -localize:boolean - -boolean:boolean - {-package_key:required} - {-parameter:required} - {-default ""} -} { - Gets an instance parameter for the package corresponding to package_key. +if {![db_table_exists apm_parameters]} { - Note that this makes the assumption that the package is a singleton. + ad_proc -public parameter::get_from_package_key { + -localize:boolean + -boolean:boolean + {-package_key:required} + {-parameter:required} + {-default ""} + } { + ns_log notice "parameter::get_from_package_key: called during initialization:" \ + "$package_key.$parameter -> '$default' (default)" + return $default + } - New packages should use global parameters instead. +} else { - @param package_key what package to get the parameter from. We will try - to get the package_id from the package_key. This - may cause an error if there are more than one - instance of this package - @param parameter which parameter's value to get - @param default what to return if we don't find a value -} { - # - # 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] + ad_proc -public parameter::get_from_package_key { + -localize:boolean + -boolean:boolean + {-package_key:required} + {-parameter:required} + {-default ""} + } { + Gets an instance parameter for the package corresponding to package_key. - # - # 2. Try to get the value from a global package parameter. - # - if {$value eq ""} { - set value [parameter::get_global_value \ - -localize=$localize_p \ - -boolean=$boolean_p \ - -package_key $package_key \ - -parameter $parameter \ - -default ""] - } + Note that this makes the assumption that the package is a singleton. - # - # 3. Try to get the value from the package_id of this package_key - # and use the standard parameter::get function to get the - # value. Note that this lookup only makes sense for singleton - # packages. - # - if {$value eq ""} { - if {[apm_package_singleton_p $package_key]} { - set value [parameter::get \ + New packages should use global parameters instead. + + @param package_key what package to get the parameter from. We will try + to get the package_id from the package_key. This + may cause an error if there are more than one + instance of this package + @param parameter which parameter's value to get + @param default what to return if we don't find a value + } { + # + # 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 the value from a global package parameter. + # + if {$value eq ""} { + set value [parameter::get_global_value \ -localize=$localize_p \ -boolean=$boolean_p \ - -package_id [apm_package_id_from_key $package_key] \ + -package_key $package_key \ -parameter $parameter \ - -default $default \ - ] - } else { - ns_log notice "tried to lookup parameter $parameter from non-singleton package $package_key" - set value $default + -default ""] } - } - return $value -} + # + # 3. Try to get the value from the package_id of this package_key + # and use the standard parameter::get function to get the + # value. Note that this lookup only makes sense for singleton + # packages. + # + if {$value eq ""} { + if {[apm_package_singleton_p $package_key]} { + set value [parameter::get \ + -localize=$localize_p \ + -boolean=$boolean_p \ + -package_id [apm_package_id_from_key $package_key] \ + -parameter $parameter \ + -default $default \ + ] + } else { + ns_log notice "tried to lookup parameter $parameter from non-singleton package $package_key" + set value $default + } + } + return $value + } +} # Local variables: # mode: tcl # tcl-indent-level: 4