Issue #979 resolved

change to autoreload feature so that it can regenerate static content upon modification

created an issue

[Sorry for having posted this in the mailing list earlier, only now did I notice Trac is the preferred way to submit patches.]

I am not sure others will find this useful, but I modified the autoreload feature so that (besides restarting the application when python code is modified) it also runs a user-specified external command to regenerate static content when something in engine.reload_files changes.

When a non-python file in engine.reload_files gets created, modified or deleted then the command specified in the config item 'engine.autoreload_external_regenerate_cmd' gets executed through the shell. Also, when an item in engine.reload_files turns out to be a directory then it recursively watches all of its subdirs for changes.

These changes work well for me because when I edited HTML, CSS or JS code I had to manually run the modified files through the templating program before being able to see the changes. This solves that problem while making use of cherrypy's own monitoring code. Perhaps others using a similar setup will find this useful.

The patch is against the latest stable release (3.1.2)


All the best,


Comments (2)

  1. Robert Brewer

    I think that if we were going to add an extension point here it would be a function, not a shell command (and if you wanted to run a shell command, then your user-provided function could do so).

    However, we don't even need to be that complicated; since the Autoreload plugin calls `engine.exit`, just write an engine plugin for the 'stop' or 'exit' channel that does the regeneration (or whatever other) step.

  2. Log in to comment