Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 13 Mar 2003 14:54:35 -0000 1.19 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 2 Apr 2003 15:56:25 -0000 1.20 @@ -279,6 +279,7 @@ Marks the file of the indicated path to be watched. If the file changes, it will be reloaded prior to the next page load. + @param path The path of the file relative to server root } { nsv_set apm_reload_watch $path 1 } @@ -290,6 +291,8 @@ is not specified. If the file is not watched this procedure does nothing. + @param path The path relative to server root of the file to stop watching. + @author Peter Marklund } { if { ![empty_string_p $path] } { @@ -299,6 +302,44 @@ } } +ad_proc -public apm_file_watchable_p { path } { + Given the path of a file determine if it is + appropriate to be watched for reload. The file should + should be db compatible with system and be of right + type (for example contain tcl procs). + + @param The path of the file relative to server root + + @return 1 If file is watchable and 0 otherwise. The proc will return 0 if the + file doesn't exist. + + @see apm_guess_file_type + @see apm_guess_db_type + + @author Peter Marklund +} { + # The apm_guess procs need package_key and a path relative to package root + # I'm letting the regexp be forgiving so the proc will work with absolute paths + regexp {packages/([^/]+)/(.*)$} $path match package_key package_rel_path + + # Check the db type + set file_db_type [apm_guess_db_type $package_key $package_rel_path] + set right_db_type_p [expr [empty_string_p $file_db_type] || \ + [string equal $file_db_type [db_type]]] + + # Check the file type + set file_type [apm_guess_file_type $package_key $package_rel_path] + # I would like to add test_procs to the list but currently test_procs files are used to register test cases + # and we don't want to resource these files in every interpreter. Test procs should be defined in test_init files. + set watchable_file_types [list tcl_procs query_file] + set right_file_type_p [expr [lsearch -exact $watchable_file_types $file_type] != -1] + + # Both db type and file type must be right + set watchable_p [expr $right_db_type_p && $right_file_type_p] + + return $watchable_p +} + ad_proc -private apm_watch_all_files { package_key } { Watch all Tcl procs and xql query files in the given package @@ -307,14 +348,9 @@ } { set files [ad_find_all_files [acs_root_dir]/packages/$package_key] foreach file [lsort $files] { - set file_db_type [apm_guess_db_type $package_key $file] - set file_type [apm_guess_file_type $package_key $file] - - set right_db_type [expr [empty_string_p $file_db_type] || \ - [string equal $file_db_type [db_type]]] - - if { $right_db_type && [expr [string equal $file_type tcl_procs] || [string equal $file_type query_file]] } { - apm_file_watch [ad_make_relative_path $file] + set rel_path [ad_make_relative_path $file] + if { [apm_file_watchable_p $rel_path] } { + apm_file_watch $rel_path } } } 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.38 -r1.39 --- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 2 Apr 2003 13:48:38 -0000 1.38 +++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 2 Apr 2003 15:56:25 -0000 1.39 @@ -568,7 +568,8 @@ # This is a singleton package. Instantiate it automatically, but don't mount. # Using empty context_id - apm_package_instance_new $version(package-name) "" $package_key + apm_package_instance_new -instance_name $version(package-name) \ + -package_key $package_key } } else { # After upgrade Tcl proc callback 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.44 -r1.45 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 2 Apr 2003 13:48:39 -0000 1.44 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 2 Apr 2003 15:56:25 -0000 1.45 @@ -1349,18 +1349,21 @@ } ad_proc -public apm_package_instance_new { - {-package_id 0} - instance_name - context_id - package_key + {-package_key:required} + {-instance_name ""} + {-package_id ""} + {-context_id ""} } { Creates a new instance of a package and calls the post instantiation proc, if any. If the package is a singleton and already exists then this procedure will silently do nothing. + @param package_key The package_key of the package to instantiate. @param instance_name The name of the package instance, defaults to the pretty name of the package type. - + @param package_id The id of the new package. Optional. + @param context_id The context_id of the new package. Optional. + @return The id of the instantiated package } { if { [empty_string_p $instance_name] } { @@ -1369,7 +1372,7 @@ where package_key = :package_key}] } - if {$package_id == 0} { + if { [empty_string_p $package_id] } { set package_id [db_null] } Index: openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 2 Apr 2003 13:48:39 -0000 1.23 +++ openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 2 Apr 2003 15:56:25 -0000 1.24 @@ -109,7 +109,9 @@ } # Instantiate the package - set package_id [apm_package_instance_new $package_name $context_id $package_key] + set package_id [apm_package_instance_new -instance_name $package_name \ + -context_id $context_id \ + -package_key $package_key] # Mount the package site_node::mount -node_id $node_id -object_id $package_id