Index: openacs-4/packages/acs-admin/acs-admin.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/acs-admin.info,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-admin/acs-admin.info 9 May 2001 22:32:25 -0000 1.8 +++ openacs-4/packages/acs-admin/acs-admin.info 29 May 2001 01:46:29 -0000 1.9 @@ -4,8 +4,8 @@ ACS Administration ACS Administration Services - t t + t @@ -42,6 +42,7 @@ + @@ -59,6 +60,8 @@ + + @@ -128,6 +131,8 @@ + + Index: openacs-4/packages/acs-admin/www/apm/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/index.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-admin/www/apm/index.tcl 13 May 2001 01:53:18 -0000 1.4 +++ openacs-4/packages/acs-admin/www/apm/index.tcl 29 May 2001 01:46:29 -0000 1.5 @@ -120,9 +120,9 @@ It is enabled if it is scheduled to run at server startup and deliverable by the request processor. -

If a Tcl library file (*-procs.tcl) is being watched, -the request processor monitors it, reloading it into running interpreters -whenever it is changed. This is useful while developing library code +

If a Tcl library file (*-procs.tcl) or query file (*.xql) is being +watched, the request processor monitors it, reloading it into running interpreters +whenever it is changed. This is useful during development (so you don't have to restart the server for your changes to take effect). To watch a file, click its package key above, click Manage file information on the next screen, and click watch next to Index: openacs-4/packages/acs-admin/www/apm/version-files.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/version-files.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-admin/www/apm/version-files.tcl 5 Apr 2001 18:23:38 -0000 1.2 +++ openacs-4/packages/acs-admin/www/apm/version-files.tcl 29 May 2001 01:46:29 -0000 1.3 @@ -91,7 +91,7 @@ doc_body_append "" } else { if { $installed_p == "t" } { - if { $file_type == "tcl_procs" } { + if { $file_type == "tcl_procs" || $file_type == "query_file" } { if { [nsv_exists apm_reload_watch "packages/$package_key/$path"] } { # This procs file is already being watched. doc_body_append " watch " Index: openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl 26 May 2001 19:32:40 -0000 1.16 +++ openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl 29 May 2001 01:46:29 -0000 1.17 @@ -362,6 +362,12 @@ # # The file_tag parameter is for later flushing of a series # of queries when a particular query file has been changed. +# +# DRB: it is now used to track the mtime of the query file when loaded, +# used by the APM to determine when a package should be reloaded. This +# code depends on the file tag parameter being set to the actual file path +# to the query file. + proc db_qd_internal_load_queries {file_pointer file_tag} { # While there are surely efficient ways of loading large files, # we're going to assume smaller files for now. Plus, this doesn't happen @@ -421,6 +427,10 @@ # Store the query db_qd_internal_store_cache $one_query } + + set relative_path [string range $file_tag \ + [expr { [string length [acs_root_dir]] + 1 }] end] + nsv_set apm_library_mtime $relative_path [file mtime $file_tag] } @@ -443,9 +453,6 @@ # See if we have the correct location for this query ns_log Notice "QD= query $fullquery_name from [db_fullquery_get_load_location $fullquery_array]" - # Let's reload this query file for now (ben) - db_qd_load_query_file [db_fullquery_get_load_location $fullquery_array] - # reload the fullquery set fullquery_array [nsv_get OACS_FULLQUERIES $fullquery_name] Index: openacs-4/packages/acs-subsite/acs-subsite.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/acs-subsite.info,v diff -u -r1.10 -r1.11 --- openacs-4/packages/acs-subsite/acs-subsite.info 15 May 2001 16:59:00 -0000 1.10 +++ openacs-4/packages/acs-subsite/acs-subsite.info 29 May 2001 01:46:29 -0000 1.11 @@ -579,8 +579,6 @@ - - @@ -607,30 +605,30 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 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.6 -r1.7 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 5 May 2001 17:39:19 -0000 1.6 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs.tcl 29 May 2001 01:46:29 -0000 1.7 @@ -402,7 +402,8 @@ $type is not specified) which support a given database (if specified) in a version. @param type Optionally specifiy what type of files to check, for instance "tcl_procs" @param db_type Optionally specifiy what type of database support to check, for instance - "postgresql" + "postgresql". All files of the given type that are used by the given database version are + returned (i.e. all database-agnostic as well as the proper database-specific files). @param version_id The version to retrieve the file list from. } { @@ -412,7 +413,7 @@ set type_sql "" } if { ![empty_string_p $db_type] } { - set db_type_sql "and db_type = :db_type" + set db_type_sql "and (db_type = :db_type or db_type is null)" } else { set db_type_sql "" } Index: openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 24 Apr 2001 22:38:12 -0000 1.5 +++ openacs-4/packages/acs-tcl/tcl/apm-procs-postgresql.xql 29 May 2001 01:46:29 -0000 1.6 @@ -104,19 +104,6 @@ - - - - - select case when count(*) = 0 then 0 else 1 end - from apm_package_versions - where package_key = :package_key - and version_name = :version_name - - - - - 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.11 -r1.12 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 27 Apr 2001 01:41:12 -0000 1.11 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 29 May 2001 01:46:29 -0000 1.12 @@ -30,7 +30,7 @@ # # apm_library_mtime($path) # -# The modification time of $file (a *-procs.tcl or *-init.tcl file) the +# The modification time of $file (a *-procs.tcl, *-init.tcl or .xql file) # when it was last loaded. # # apm_version_procs_loaded_p($version_id) @@ -162,7 +162,6 @@ if { ![empty_string_p $file_info_var] } { upvar $file_info_var file_info } - set files [apm_version_file_list -type "tcl_procs" $version_id] db_1row package_key_select "select package_key from apm_package_version_info where version_id = :version_id" @@ -173,7 +172,8 @@ select file_id, path from apm_package_files where version_id = :version_id - and file_type = 'tcl_procs' + and file_type in ('tcl_procs', 'query_file') + and (db_type is null or db_type = '[db_type]') order by path } { set full_path "[acs_package_root_dir $package_key]/$path" @@ -183,6 +183,7 @@ # which differs the mtime it had when last loaded, mark to be loaded. if { [file isfile $full_path] } { set mtime [file mtime $full_path] + if { ![nsv_exists apm_library_mtime $relative_path] || \ [nsv_get apm_library_mtime $relative_path] != $mtime } { lappend changed_files $relative_path @@ -217,7 +218,7 @@ where version_id = :version_id } - foreach file [apm_version_file_list -type "tcl_procs" $version_id] { + foreach file [apm_version_file_list -type "tcl_procs" -db_type [db_type] $version_id] { # If $file has never been loaded, i.e., it has been added to the version # since the version was initially loaded, return needs_reload. if { ![nsv_exists apm_library_mtime "packages/$package_key/$file"] } { @@ -233,6 +234,22 @@ } } + foreach file [apm_version_file_list -type "query_file" -db_type [db_type] $version_id] { + # If $file has never been loaded, i.e., it has been added to the version + # since the version was initially loaded, return needs_reload. + if { ![nsv_exists apm_library_mtime "packages/$package_key/$file"] } { + return "needs_reload" + } + + set full_path "[acs_package_root_dir $package_key]/$file" + # If $file had a different mtime when it was last loaded, return + # needs_reload. (If the file should exist but doesn't, just skip it.) + if { [file exists $full_path] && + [file mtime $full_path] != [nsv_get apm_library_mtime "packages/$package_key/$file"] } { + return "needs_reload" + } + } + return "up_to_date" } @@ -429,7 +446,11 @@ ns_log "Notice" "APM: Reloading $file..." # File is usually of form packages/package_key set file_path "[acs_root_dir]/$file" - apm_source [acs_root_dir]/$file + switch [apm_guess_file_type "" $file] { + tcl_procs { apm_source [acs_root_dir]/$file } + query_file { db_qd_load_query_file [acs_root_dir]/$file } + } + nsv_set apm_library_mtime $file [file mtime $file_path] set reloaded_files($file) 1 } Index: openacs-4/packages/acs-tcl/tcl/apm-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-tcl/tcl/apm-procs.xql 27 Apr 2001 01:41:12 -0000 1.3 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.xql 29 May 2001 01:46:29 -0000 1.4 @@ -4,7 +4,7 @@ - select case when count(*) > 0 then 0 else 1 end from apm_package_versions + select case when count(*) = 0 then 0 else 1 end from apm_package_versions where version_id = :version_id and enabled_p = 't' @@ -23,7 +23,8 @@ select file_id, path from apm_package_files where version_id = :version_id - and file_type = 'tcl_procs' + and file_type in ('tcl_procs', 'query_file') + and (db_type is null or db_type = '[db_type]') order by path