apm_load_libraries

one of the documented procedures in this installation of the ACS
Usage:
apm_load_libraries   procs_or_init
What it does:
Loads all -procs.tcl (if $procs_or_init is "procs") or -init.tcl (if $procs_or_init is "init") files into the current interpreter for installed, enabled packages. Only loads files which have not yet been loaded. This is intended to be called only during server initialization (since it loads libraries only into the running interpreter, as opposed to in *all* active interpreters).
Defined in: /web/philip/packages/acs-core/apm-procs.tcl

Source code:


    if { ![string equal $procs_or_init "procs"] && ![string equal $procs_or_init "init"] } {
	error "Argument to apm_load_libraries must be \"procs\" or \"init\""
    }

    ns_log "Notice" "Loading packages' *-$procs_or_init.tcl files..."

    # Load in sorted order of package_key and path.
    set files [db_list "
        select package_key || '/' || path
        from   apm_package_files f, apm_package_version_info v
        where  f.version_id = v.version_id
        and    v.enabled_p = 't'
        and    f.file_type = 'tcl_$procs_or_init'
        order by package_key, path
    "]

    # Release all outstanding database handles (since the file we're sourcing
    # might be using the ns_db database API as opposed to the new db_* API).
    db_release_unused_handles

    # This will be the first time loading for each of these files (since if a
    # file has already been loaded, we just skip it in the loop below).
    global apm_first_time_loading_p
    set apm_first_time_loading_p 1

    foreach file $files {
	# If the file has never been loaded, source it.
	if { ![nsv_exists apm_library_mtime $file] } {
	    if { [file exists "[acs_root_dir]/packages/$file"] } {
		ns_log "Notice" "Loading packages/$file..."

		# Remember that we've loaded the file.
		apm_source "[acs_root_dir]/packages/$file"
		nsv_set apm_library_mtime $file [file mtime "[acs_root_dir]/packages/$file"]

		# Release outstanding database handles (in case this file
		# used the db_* database API and a subsequent one uses
		# ns_db).
		db_release_unused_handles

		ns_log "Notice" "Loaded packages/$file."
	    } else {
		ns_log "Error" "Unable to load packages/$file - file is marked as contained in a package but is not present in the filesystem"
	    }
	}
    }

    unset apm_first_time_loading_p

    # Remember that we've now loaded every enabled version.
    db_foreach "
        select version_id
        from apm_package_version_info
        where enabled_p = 't'
    " {
	nsv_set apm_version_${procs_or_init}_loaded_p $version_id 1
    }


philg@mit.edu