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.95 -r1.96 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 27 Oct 2014 16:40:05 -0000 1.95 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 7 Aug 2017 23:47:59 -0000 1.96 @@ -908,7 +908,14 @@ ad_proc -private apm_package_installed_p_not_cached { package_key } { - return [db_string apm_package_installed_p {} -default 0] + if {[catch {set installed_p [db_string apm_package_installed_p { + select 1 from apm_package_versions + where package_key = :package_key + and installed_p = 't' + } -default 0]}]} { + set installed_p 0 + } + return $installed_p } ad_proc -public apm_package_enabled_p { @@ -941,13 +948,7 @@ Return the highest version of the indicated package. @return the version_id of the highest installed version of a package. } { - return [db_exec_plsql apm_highest_version { - begin - :1 := apm_package.highest_version ( - package_key => :package_key - ); - end; - }] + return [db_exec_plsql apm_highest_version {}] } ad_proc -public apm_highest_version_name {package_key} { @@ -961,13 +962,7 @@ @return The number of instances of the indicated package. } { - return [db_exec_plsql apm_num_instances { - begin - :1 := apm_package.num_instances( - package_key => :package_key - ); - end; - }] + return [db_exec_plsql apm_num_instances {}] } @@ -1050,8 +1045,7 @@ } # Update the cache. - db_foreach apm_parameter_cache_update { - } { + db_foreach apm_parameter_cache_update {} { ad_parameter_cache -set $attr_value $package_id $parameter_name } return $parameter_id @@ -1107,13 +1101,7 @@ Removes a dependency from the system. } { - db_exec_plsql dependency_remove { - begin - apm_package_version.remove_dependency( - dependency_id => :dependency_id - ); - end; - } + db_exec_plsql dependency_remove {} } ad_proc -public apm_interface_add { @@ -1132,30 +1120,15 @@ set interface_id [db_null] } - return [db_exec_plsql interface_add { - begin - :1 := apm_package_version.add_interface( - interface_id => :interface_id, - version_id => :version_id, - interface_uri => :interface_uri, - interface_version => :interface_version - ); - end; - }] + return [db_exec_plsql interface_add {}] } ad_proc -public apm_interface_remove {interface_id} { Removes a interface from the system. } { - db_exec_plsql interface_remove { - begin - apm_package_version.remove_interface( - interface_id => :interface_id - ); - end; - } + db_exec_plsql interface_remove {} } ad_proc -public apm_version_get { @@ -1232,8 +1205,12 @@ } { set var ::apm::package_id_from_key($package_key) if {[info exists $var]} {return [set $var]} - set $var [util_memoize [list apm_package_id_from_key_mem $package_key]] - #set $var [ns_cache_eval ns:memoize apm_package_id_from_key_$package_key [list apm_package_id_from_key_mem $package_key]] + set result [util_memoize [list apm_package_id_from_key_mem $package_key]] + #set result [ns_cache_eval ns:memoize apm_package_id_from_key_$package_key [list apm_package_id_from_key_mem $package_key]] + if {$result != 0} { + set $var $result + } + return $result } ad_proc -private apm_package_id_from_key_mem {package_key} { @@ -1294,7 +1271,7 @@ } ad_proc -private apm_package_url_from_id_mem {package_id} { - return [db_string apm_package_url_from_id {*SQL*} -default {}] + return [db_string apm_package_url_from_id {} -default {}] } # @@ -1317,13 +1294,25 @@ # package_key -> version_id # -ad_proc -public apm_version_id_from_package_key { package_key } { - Return the id of the enabled version of the given package_key. +ad_proc -public apm_version_id_from_package_key { + {-all:boolean} + package_key +} { + Return the id of the (per default enabled) version of the given package_key. If no such version id can be found, returns the empty string. + @param all when specified, return the the enabled or disabled version_ids of the package_key. + @param package_key @author Peter Marklund + + @return the supposedly unique version_id for the enabled package, or a list of + all the enabled and disabled versions when -all flag is specified } { - return [db_string get_id {} -default ""] + if {$all_p} { + return [db_list get_id {}] + } else { + return [db_string get_enabled_id {} -default ""] + } } # @@ -1342,7 +1331,7 @@ ad_proc -private apm_package_key_from_version_id_mem {version_id} { Returns the package_key for the given APM package version id. Goes to the database - everytime called. + every time called. @author Peter Marklund (peter@collaboraid.biz) } { @@ -1710,15 +1699,25 @@ } set test_arg_list "" + set test_arg_list_spec "" foreach arg_name [apm_arg_names_for_callback_type -type $type] { lappend test_arg_list -$arg_name value + lappend test_arg_list_spec -${arg_name}:required } if { $test_arg_list eq "" } { # The callback proc should take no args return [expr {[info args ::$proc_name] eq ""}] } + + if {[info commands ::nsf::cmd::info] ne ""} { + # + # We can compare the signature of via nsf procs + # + return [expr {[::nsf::cmd::info parameter ::$proc_name] eq $test_arg_list_spec}] + } + # The callback proc should have required arg switches. Check # that the ad_proc arg parser doesn't throw an error with # test arg list @@ -1863,8 +1862,9 @@ and d.version_id = v.version_id and v.enabled_p = 't' } { - if { ![info exists installed_provides($service_uri)] || \ - [apm_version_names_compare $installed_provides($service_uri) $service_version] == -1 } { + if { ![info exists installed_provides($service_uri)] + || [apm_version_names_compare $installed_provides($service_uri) $service_version] == -1 + } { set installed_provides($service_uri) $service_version } }