Forum OpenACS Q&A: Watching Files - Quick Select

Collapse
Posted by defunct defunct on
I'm assuming the following doesn't already exists (unless I've missed
it), but is there currently a way to set 'watches' for all files for a
package in one step, rather than selecting each one?

If I imagine this isn't too difficult to do? Is it something that
could slip into 4.6?

The reason for asking is I'm currently writing a package with >20
files I want to watch. Unfortunately, it would appear that when one
renames an existing file, re-scans the package files, and re-sets the
wathes, the system still insists on trying to watch the original, and
this also causes query diaptcher problems as its now unable to locate
the new query in the new file.

This is solved by restarting the server... but.... it means reapplying
the watch to 20 odd files everytime.

Any advice/thoughts?

Collapse
Posted by Peter Alberer on

A very poor solution i sometimes use during development is to put all the tcl-code into one -proc.tcl file and reload that.

Collapse
Posted by Don Baccus on
No, the feature does not exist and unfortunately you're too late with your request for 4.6.  It wouldn't be hard to add, make sure we do it for 4.7.  For new package developers it would be very useful.

There is a "reload" link that appears next to your package name in the main APM index page that you'll find useful in the interim ...

Collapse
Posted by Michael Hinds on
Simon,

How about putting this into 0-package_key-startup-procs.tcl:

# if this is the dev server, watch the contents of package_key/tcl
if {[string equal [info host] your_server_name]} {

  cd acs_root/packages/package_key/tcl
  set files [glob *.tcl]
  foreach file $files {

    ns_log notice "0-package_key-startup-procs.tcl: watching $file"
    apm_file_watch "packages/package_key/tcl/$file"

  }

}
This watches all .tcl files for your package at server startup.
Collapse
Posted by Tom Jackson on

You might avoid the use of tcl's cd command and use:

set directory $acs_root/packages/$package_key/tcl
set files [glob -nocomplain -directory $directory *.tcl]
....

The -nocomplain switch prevents an error when no files are found.