apm_file_watchable_p (public)

 apm_file_watchable_p path

Defined in packages/acs-tcl/tcl/apm-file-procs.tcl

Given the path of a file determine if it is appropriate to be watched for reload. The file should be db compatible with the system and be of right type (for example contain Tcl procs or xql queries).

Parameters:
path (required)
The path of the file relative to server root
Returns:
1 If file is watchable and 0 otherwise. The proc will throw an error if the file doesn't exist or if the given path cannot be parsed as a path relative to server root.
Author:
Peter Marklund
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 apm_get_watchable_files apm_get_watchable_files (private) apm_file_watchable_p apm_file_watchable_p apm_get_watchable_files->apm_file_watchable_p packages/acs-admin/www/apm/version-files.tcl packages/acs-admin/ www/apm/version-files.tcl packages/acs-admin/www/apm/version-files.tcl->apm_file_watchable_p apm_guess_db_type apm_guess_db_type (public) apm_file_watchable_p->apm_guess_db_type apm_guess_file_type apm_guess_file_type (public) apm_file_watchable_p->apm_guess_file_type db_type db_type (public) apm_file_watchable_p->db_type

Testcases:
No testcase defined.
Source code:
    # The apm_guess procs need package_key and a path relative to package root
    # so parse those out of the given path
    if { [regexp {^packages/([^/]+)/(.*)$} $path match package_key package_rel_path] } {
        if { ![file exists "$::acs::rootdir/$path"] } {
            error "apm_file_watchable_p: path $path does not correspond to an existing file"
        }
    } else {
        error "apm_file_watchable_p: path $path cannot be parsed as a path relative to server root"
    }

    # Check the db type
    set file_db_type [apm_guess_db_type $package_key $package_rel_path]
    set right_db_type_p [expr {$file_db_type eq "" || $file_db_type eq [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 test_procs]
    set right_file_type_p [expr {$file_type in $watchable_file_types}]

    # Both db type and file type must be right
    set watchable_p [expr {$right_db_type_p && $right_file_type_p}]

    return $watchable_p
Generic XQL file:
packages/acs-tcl/tcl/apm-file-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/apm-file-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/apm-file-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: