paster serve has --reload option to auto-restart serving wsgi application when any of Python source files or the CONFIG_FILE changes. How to make paster initiate auto-restart also when some other file (not Python source file) changes?

UPDATE

watch_file() function suggested by mksh looks like the solution to the problem. However mksh suggested adding its invocation to the application's entry point which seems to be more invasive than it should. Can I (non-intrusively) extend Paste's serve command adding new option which would result in invocation of watch_file() with filenames read from the app's section in CONFIG_FILE?

有帮助吗?

解决方案

See Paster source link

So, you can watch your non-source files as simple as putting such lines at bottom of your application`s entry points:

from paste.reloader import watch_file

#
# logic that puts list of your non-source file names suitable 
# for open() into iterable non_source_file_list
#

for non_source_file in non_source_file_list:
    watch_file(non_source_file_name)

In general, try to rely more on source code than documentation when working with such modern and really written in pythonic style frameworks as Paste, their code is mostly well documented and futhermore self-documenting .

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top