Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl,v diff -u -r1.78 -r1.79 --- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 5 Jul 2004 14:58:27 -0000 1.78 +++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 8 Jul 2004 14:19:58 -0000 1.79 @@ -717,12 +717,30 @@ apm_load_queries -packages $package_key } - if { $upgrade_p } { + # Get the callbacks in an array, since we can't rely on the + # before-upgrade being in the db (since it might have changed) + # and the before-install definitely won't be there since + # it's not added til later here. + + array set callbacks $version(callbacks) + + if {$upgrade_p} { # Run before-upgrade - apm_invoke_callback_proc -version_id $version_id -type before-upgrade -arg_list [list from_version_name $upgrade_from_version_name to_version_name $version(name)] + if {[info exists callbacks(before-upgrade)]} { + apm_invoke_callback_proc \ + -proc_name $callbacks(before-upgrade) \ + -version_id $version_id \ + -type before-upgrade \ + -arg_list [list from_version_name $upgrade_from_version_name to_version_name $version(name)] + } } else { # Run before-install - apm_invoke_callback_proc -version_id $version_id -type before-install + if {[info exists callbacks(before-install)]} { + apm_invoke_callback_proc \ + -proc_name $callbacks(before-install) \ + -version_id $version_id \ + -type before-install + } } if { $load_data_model_p } { 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.70 -r1.71 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 16 Jun 2004 01:34:24 -0000 1.70 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 8 Jul 2004 14:19:58 -0000 1.71 @@ -1214,7 +1214,6 @@ if { [empty_string_p $version_id] } { set version_id [apm_version_id_from_package_key $package_key] } - return [db_string select_proc {} -default ""] } @@ -1256,6 +1255,7 @@ } ad_proc -public apm_invoke_callback_proc { + {-proc_name {}} {-version_id ""} {-package_key ""} {-arg_list {}} @@ -1265,6 +1265,11 @@ for a given package version. Any errors during invocation are logged. + @param callback_proc if this is provided it is called + instead of attempting to look up the proc via the package_key or version_id + (needed for before-install callbacks since the db is not populated when those + are called). + @return 1 if invocation was carried out successfully, 0 if no proc to invoke could be found. Will propagate any error thrown by the callback. @@ -1273,11 +1278,13 @@ } { array set arg_array $arg_list - set proc_name [apm_get_callback_proc \ - -version_id $version_id \ - -package_key $package_key \ - -type $type] - + if {[empty_string_p $proc_name]} { + set proc_name [apm_get_callback_proc \ + -version_id $version_id \ + -package_key $package_key \ + -type $type] + } + if { [empty_string_p $proc_name] } { if { [string equal $type "after-instantiate"] } { # We check for the old proc on format: package_key_post_instantiation package_id @@ -1293,7 +1300,7 @@ $proc_name $arg_array(package_id) return 1 - + } else { # No other callback procs to fall back on return 0